.NET Core 1.0 和 EntityFramework 7 不兼容

.NET Core 1.0 and EntityFramework 7 Not Compatible

我已经升级到 Visual Studio 代码 1.0.0,并且我正在尝试改造我之前在 VSCode 中从事的 ASP.NET 核心项目,在新版本发布之前. VSCode 现在在配置方面似乎大不相同。我曾与 this tutorial and these samples 合作过。我在让我的项目的 MVC6 方面编译和正常工作方面取得了合理的成功,但是 EntityFramework 7 方面是不行的。

当我对我的项目执行 dotnet restore 时,出现以下错误:

Package EntityFramework.Core 7.0.0-rc1-final is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0).

我一直在或多或少地随机试验 project.json 以期找到解决方案,但我似乎没有取得太大进展。 netcoreapp1.0 是否仍然太新而无法与 EntityFramework 兼容?有哪些选项可用?

顺便说一下,这是我的 project.json。它与上面提到的 HelloMvcApi 示例有相当多的库存,但添加了 EntityFramework.Core 依赖项:

{
  "compilationOptions": {
    "emitEntryPoint": true,
    "debugType": "portable"
  },
  "dependencies": {
    "Microsoft.AspNetCore.Mvc.Core": "1.0.0-*",
    "Microsoft.AspNetCore.Mvc.Formatters.Json": "1.0.0-*",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*",
    "Microsoft.Extensions.Logging.Console": "1.0.0-*",
    "EntityFramework.Core": "7.0.0-rc1-final",
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.0-*"
    }
  },
  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "portable-net45+wp80+win8+wpa81+dnxcore50"
      ]
    }
  },
  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
      "version": "1.0.0-*",
      "imports": "portable-net45+wp80+win8+wpa81+dnxcore50"
    }
  },
  "scripts": {
    "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
  }
}

this announcement of breaking changes in RC2所述:

The EntityFramework.* packages and namespaces are changing to Microsoft.EntityFrameworkCore.*

所以您只需要将您的引用切换为指向更新版本即可:

"Microsoft.EntityFrameworkCore": "1.0.0-*",