.NET Core 1.0 和 EntityFramework 7 不兼容 [英] .NET Core 1.0 and EntityFramework 7 Not Compatible

查看:28
本文介绍了.NET Core 1.0 和 EntityFramework 7 不兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已升级到 Visual Studio Code 1.0.0,并且正在尝试改造我之前在 VSCode 中工作的 ASP.NET Core 项目,在新版本发布之前.VSCode 现在在配置方面似乎完全不同.我使用过本教程这些示例.我在编译项目的 MVC6 方面并正常工作方面取得了合理的成功,但 EntityFramework 7 方面是行不通的.

I've upgraded to Visual Studio Code 1.0.0 and I'm trying to retrofit an ASP.NET Core project I was working on in VSCode previously, before the new release. VSCode is seemingly quite different now in terms of configuration. I've worked with this tutorial and these samples. I'm having reasonable success getting the MVC6 aspect of my project compiling and working properly, but the EntityFramework 7 aspect is a no-go.

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

When I do a dotnet restore on my project, I get the following error:

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

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

I've been experimenting more-or-less randomly with the project.json in the hopes of finding a solution, but I don't seem to be making much progress. Is netcoreapp1.0 still just too new to be retro-compatible with EntityFramework? What options are available?

顺便说一下,这是我的 project.json.它几乎来自上面提到的 HelloMvcApi 示例,但添加了 EntityFramework.Core 依赖项:

Here's my project.json, by the way. It's pretty much stock from the HelloMvcApi sample mentioned above, but with the addition of the EntityFramework.Core dependency:

{
  "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%"
  }
}

推荐答案

此关于 RC2 重大更改的公告中所述 :

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

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

所以你只需要切换你的引用指向更新的版本:

So you'll just need to switch your reference to point to the updated version :

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

这篇关于.NET Core 1.0 和 EntityFramework 7 不兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆