Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework Core 2.0 on .NET 4.6.1

Tags:

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.

like image 247
user281921 Avatar asked Jun 06 '17 15:06

user281921


People also ask

Does Entity Framework core work with .NET framework?

You can use EF Core in APIs and applications that require the full . NET Framework, as well as those that target only the cross-platform .

Can you mix .NET Framework and .NET core?

At this point, if your NuGet dependencies are compatible with both your netcore and netframework targets you may be done! The big news here is that most of your NuGet dependencies are compatible with both. All of the most downloaded NuGet packages are either multi-targeted, or have packages for each target.

What is the latest version of Entity Framework Core?

The most recent Entity Framework Core 6.0 (EF Core 6) was released on 10 November 2021.


1 Answers

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" />
like image 157
user281921 Avatar answered Sep 19 '22 09:09

user281921