Reputation: 8203
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?
Upvotes: 8
Views: 7009
Reputation: 2705
In my case, I had a project targetting both .NET Standard 2.0 and .NET Core:
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
So they solution was to apply a condition to use the older version of the Microsoft.EntityFrameworkCore
package for .NET Standard 2.0, and the newer one for .NET 6:
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.17" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.29" />
</ItemGroup>
Upvotes: 1
Reputation: 414
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/
Upvotes: 6
Reputation: 8203
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.
Upvotes: 5