can not upgrade from EF Core 1.1.2 to version 2.0.0

好久不见. 提交于 2019-12-11 04:22:50

问题


All, I recently started working on a project that uses EF Core 1.1.2. I saw where 2.0 was released because I started getting errors when I tried to add EF core to a project. I couldn't update the existing project, I created a brand new console project. Set the .Net framework to 4.6.1 and still had no luck. I always get the following message. Has anyone ran into this issue? thanks in advance

Install-Package : Could not install package 'Microsoft.EntityFrameworkCore.SqlServer 2.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6.1', but the package does not contain any assembly references or content files that are compatible with that framework.


回答1:


EF Core 2.0 release has been officially announced and the documentation is (partially) updated.

Of course it's not NET Core only. But the actual prerequisites for targeting Full .NET Framework are as follows:

(1) Project targeting .NET Framework 4.6.1 and above.

(2) Visual Studio 2017 with (important!) 15.3.0 update (also just released) installed

Before updating the VS I was getting the same error. After updating the error is gone and EF 2.0 package is successfully installed.




回答2:


EF Core 1.1.2 had a dependency on .NETStandard 1.3 or .NETFramework 4.5.1. So as you were targeting .NetFramework 4.5.2 everything is hunky dory.

EF Core 2.0 has a dependency on .NETStandard 2.0. This is not compatible with the .NETFramework, everything is far from hunky dory.

According to the source below you can get .NetFramework support with 2.0 tooling, which is in preview:

  • https://dotnet.myget.org/feed/dotnet-core/package/nuget/NETStandard.Library.NETFramework

The alternative would be to migrate your application so it doesn't use the .NetFramework but only targets .NETStandard libraries.

Sources

  • https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.SqlServer/2.0.0
  • https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.SqlServer/1.1.2
  • https://docs.microsoft.com/en-us/dotnet/standard/net-standard

Good luck.




回答3:


EntityFramework Core 2.0.0 is not compatible with a Target framework other than Core 2.0.0. You will need to ensure your project is targetting this and install any dependancies.

It will NOT work with the (standard) .NET framework versions, it is a 'Core' specific release.



来源:https://stackoverflow.com/questions/45693662/can-not-upgrade-from-ef-core-1-1-2-to-version-2-0-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!