使用最新的Entity Framework Core获取Newtonsoft.Json程序集错误

时间:2016-05-21 14:34:41

标签: entity-framework entity-framework-core

在为TC 2安装最新的visual studio更新后,我创建了一个新的Web Api项目。

向项目添加了实体Microsoft.EntityFrameworkCore": "1.0.0-rc2-finalMicrosoft.EntityFrameworkCore.Tools: 1.0.0-preview1-final

打开命令行并输入dotnet ef

此时我收到了一个错误:

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. 

我的工具版本是否错误?

我使用的版本是intellisense提供的版本。

摘自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"
      ]
    }
  },

3 个答案:

答案 0 :(得分:1)

这似乎是RC2中的已知问题。

我会将此标记为已回答,并等待EF团队对其进行排序。

答案 1 :(得分:1)

解决方案,节省了我的一天。

  1. 删除:

    • %USERPROFILE%\.nuget\packages\.tools\Microsoft.EntityFrameworkCore.Tools
    • %USERPROFILE%\.nuget\packages\Microsoft.EntityFrameworkCore.Tools
  2. 重新运行dotnet restore

答案 2 :(得分:0)

我还必须在project.json文件中手动添加InternalAbstractions:

    "Microsoft.DotNet.InternalAbstractions": "1.0.0",

https://github.com/dotnet/core/issues/366