Package Microsoft.EntityFramework.Core 6.0.0 is not compatible with netcoreapp 3.1

Viewed 33012

I need to install the Microsoft Entity Framework Core package. But I get this error message:

Error NU1202: Package Microsoft.EntityFrameworkCore 6.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp, Version = v3.1). Package Microsoft.EntityFrameworkCore 6.0.0 supports: net6.0 (.NETCoreApp, Version= v6.0)

The .csproj looks like this:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

</Project>
12 Answers

my problem was that I use net 5 and it tried to install the latest version of entity framework so the solution was to mark the specific requested version. in package manager console I typed:

Install-Package Microsoft.EntityFrameworkCore.Tools -Version 5.0.10

and then it was successful

I faced this problem and solve it by downloading the Package Microsoft.EntityFramework with version 5.0.10

As other people also mentioned before, the package you are trying to install is not compatible with the .Net framework used in your project. Open your project in Visual studio and then go to Tools->Nuget Package Manager->Manage Nuget Packages for Solution..., then go to Browse tab and search for "Microsoft.EntityFrameworkCore" when you found the right package click on the dropdownbox close to the version and try different Versions and expand the details to check 'Dependencies' as you may see there version 6.0.x needs at least .Net 6.0 while older versions required .Net standard. Look at the below image for your reference: enter image description here

I fixed this by adding an older package.

Open your terminal > navigate to your project and insert this

dotnet add package Microsoft.EntityFrameworkCore -v 5.0

I have encountered the similar problem but here is what I have found.

Any application with netcore 5.0 or below is not supported by or compatible with Microsoft.EntityFramework.Core 6.0.0

In order to get around this problem there is two possible options.

  1. If you can not change netcore version of the app to 6.0 you need to use compatilble version to your application which in this case will be 5.0.15

  2. If you want to use Microsoft.EntityFramework.Core 6.0.0 only than netcore version of the must be updated to 6.0

I hope this helps.

Install the latest version with major version 5 of "dotnet-ef" with this command:

dotnet tool install dotnet-ef --global --version 5.*

Uninstall the tool with this command:

dotnet tool uninstall dotnet-ef --global

I recommend this command:

dotnet tool update dotnet-ef --global --ignore-failed-sources --version 5.*

Which automatically installs or updates the tool and ignores broken or authenticated Nuget Repositories.

Install Microsoft.EntityFrameworkCore.SQLServer Version 5.0.10 and check it should get installed and you should be able use sqlserver

I have encountered a similar error when writing some unit tests using xUnit. I needed to use the InMemoryDatabase from Microsoft.EntityFrameworkCore.InMemory package which threw this error:

Package Microsoft.EntityFrameworkCore.InMemory 6.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1).
Package Microsoft.EntityFrameworkCore.InMemory 6.0.0 supports: net6.0 (.NETCoreApp,Version=v6.0)

I solved this by switching my TargetFramework in csproj from netcoreapp3.1 to net5.0 then Clean -> rebuild.

I solved it. In my situation, a problem was raised because it wanted to install the latest stable NuGet package. By default, it was version 6.0. But my project was made for .Net framework 5.0. So I chose the latest 5.0 NuGet package version - it is 5.0.13. And it worked fine.

Silly me. I got this error while trying to publish. I had previously published under .net 5. Then upgraded the project to .net 6. I didn't realize that there is a target version in the publish configuration that needed to be changed as well.

I have the same problem but with different in netcore version mine is 5.0 So I solve it by installing Microsoft.EntityFrameworkCore 5.0.17
enter image description here

The same problem I have. I solved it by typing this command:

dotnet add package -v 5.0.0 Microsoft.EntityFrameworkCore.Design

My problem was that I used .net 5 and it tried to install the latest version of the Microsoft.EntityFrameworkCore.Design so the solution was to mark the specifically requested version

Related