.NET Core 1.0和EntityFramework 7不兼容

时间:2016-04-20 15:57:26

标签: asp.net-core visual-studio-code entity-framework-core .net-core

我已升级到Visual Studio Code 1.0.0,我试图在新版本发布之前尝试改进我之前在VSCode中工作的ASP.NET核心项目。 VSCode现在在配置方面看起来非常不同。我曾与this tutorialthese 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%"
  }
}

1 个答案:

答案 0 :(得分:8)

this announcement of breaking changes in RC2中所述:

  

EntityFramework。* 包和名称空间正在更改为 Microsoft.EntityFrameworkCore。*

因此,您只需将引用切换为指向更新版本:

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