5

I am trying to install the latest Microsoft.EntityFrameworkCore 6.0.3 into a class library project targetting netstandard2.1 using Nuget Package Manager and I get this error:

Package Microsoft.EntityFrameworkCore 6.0.3 is not compatible with netstandard2.1 (.NETStandard,Version=v2.1). Package Microsoft.EntityFrameworkCore 6.0.3 supports: net6.0 (.NETCoreApp,Version=v6.0)

Can anyone help me with their guidance to fix this issue?

santosh kumar patro
  • 7,231
  • 22
  • 71
  • 143
  • You should change target framework for this class library. – Guru Stron Mar 11 '22 at 20:39
  • 1
    I think .Net Standard 2.0 will work (not sure). Can't you change to .Net 6.0? – Paul Sinnema Mar 11 '22 at 20:43
  • The [dependencies](https://www.nuget.org/packages/Microsoft.EntityFrameworkCore) clearly shows the [TFM](https://learn.microsoft.com/en-us/dotnet/standard/frameworks) of "`net6.0`" which is _waaaaay_ beyond .NET Standard 2.1 (.NET Core 2.1) –  Mar 11 '22 at 21:53
  • Why is your question tagged with both `asp.net-core-6.0` (a .NET 6 tag) and `.net-standard-2.1` which isn't? –  Mar 11 '22 at 21:59
  • @PaulSinnema _"I think .Net Standard 2.0 will work"_ - why? If .NET Standard 2.1 doesn't work (and why should it) .NET 2.0 definitely won't –  Mar 11 '22 at 22:02
  • 1
    Thanks everyone for their responses. I tried to update the classlibrary to .NETStandard 2.0 and add the nuget pacages but it also resulted the same error. I then have upgraded the project from .NETStandard2.1 to net6.0 and then tried to add the nuget packages related to EntityFramework Core 6.0.3 and it worked for me :) – santosh kumar patro Mar 14 '22 at 11:53

2 Answers2

5

After upgrading the classlibrary from .NETStandard 2.1 to net6.0 and then adding the nuget packages related to EntityFramework 6.0.3 worked for me.

santosh kumar patro
  • 7,231
  • 22
  • 71
  • 143
5

To add to Santosh's Answer.

Back in 2020 MSFT put out a statement that they were moving away from .Net Standard.

Essentially:

  • Use netstandard2.0 to share code between .NET Framework and all other platforms.

  • Use netstandard2.1 to share code between Mono, Xamarin, and .NET Core 3.x.

  • Use net5.0 for code sharing moving forward.

So with the above, transitioning class libraries to .NET 6 makes sense.

More:

https://devblogs.microsoft.com/dotnet/the-future-of-net-standard/

Craig
  • 344
  • 4
  • 9