Entity Framework Core 2.0 on .NET 4.6.1

entity-framework entity-framework-core

Question

Microsoft just announced that Entity Framework Core 2.0 will now run on .NET Standard 2.0.

.Net Standard 2.0 is compatible (if that's the right term here) with .NET Framework 4.6.1.

However when I try add the latest NuGet package I get an error telling me that I'm using the wrong version:

 Install-Package : Could not install package 
 'Microsoft.EntityFrameworkCore.SqlServer 2.0.0-preview2-25332'. 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. 

If according to the announcement I can use EF Core 2.0 with .NET Framework 4.6.1, can someone please explain, and if possible give an example of what that would look like.

1
20
6/6/2017 3:35:59 PM

Accepted Answer

It seems that in order to include .NET Standard 2.0 libraries within a .NET 4.6.1 project you need to include the NetStandard.Library.NetFramework NuGet package.

Example of current version in the packages.config file:

<package id="NETStandard.Library.NETFramework" version="2.0.0-preview1-25305-02" targetFramework="net461" />
5
6/7/2017 10:14:08 AM

Popular Answer

In addition to installing the NETStandard.Library.NETFramework package, you may also have to tell older NuGet clients that it really is compatible by adding the following to your *.csproj file.

<PropertyGroup>
  <PackageTargetFallback>netstandard2.0</PackageTargetFallback>
</PropertyGroup>


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow