Getting Newtonsoft.Json assembly error with latest Entity Framework Core

entity-framework entity-framework-core

Question

I created a new Web Api project after installing the latest visual studio updates for TC 2.

Added entity Microsoft.EntityFrameworkCore": "1.0.0-rc2-final and Microsoft.EntityFrameworkCore.Tools: 1.0.0-preview1-final to the project.

Opened a command line and typed dotnet ef.

At this point I got an error:

Could not load file or assembly 'Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified. 

Have I got the wrong tools version?

The version I used is what was available from intellisense.

Excerpt from project.json:

{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0-rc2-3002702",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
    "Microsoft.EntityFrameworkCore": "1.0.0-rc2-final",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final",
    "Microsoft.NETCore.Platforms": "1.0.1-rc2-24027",
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview1-final" ,
      "type": "build"
    }
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": "portable-net45+win8+dnxcore50"
    },
    "Microsoft.EntityFrameworkCore.Tools": {
      "imports": [ "portable-net451+win8" ],
      "version": "1.0.0-preview1-final"
    }
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "dnxcore50",
        "portable-net45+win8",
        "portable-net451+win8"
      ]
    }
  },
1
3
5/21/2016 2:51:41 PM

Accepted Answer

A workaround that saved my day.

  1. Delete:

    • %USERPROFILE%\.nuget\packages\.tools\Microsoft.EntityFrameworkCore.Tools
    • %USERPROFILE%\.nuget\packages\Microsoft.EntityFrameworkCore.Tools
  2. Re-run dotnet restore

1
6/27/2016 2:12:53 PM

Popular Answer

This appears to be known issue in RC2.

I will mark this as answered and wait for the EF team to sort it out.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow