3

I have a NetStandard2.1 library that is used for data access in a WebApi I was going to upgrade the WebApi and the data access to .NET 6.0.

dotnet --info shows the following .NET SDKs installed

NET SDKs installed:
 3.1.415 C:\Program Files\dotnet\sdk
 5.0.403 C:\Program Files\dotnet\sdk
 6.0.100-preview.4.21255.9 C:\Program Files\dotnet\sdk
 6.0.100-preview.7.21379.14 C:\Program Files\dotnet\sdk
 6.0.100 C:\Program Files\dotnet\sdk

There are only 3 packages within the data access class library.

  1. Microsoft.AspNetCore.Identity.EntityFrameworkCore (5.0.10)
  2. Microsoft.EntityframeworkCore (5.0.10)
  3. Microsoft.EntityFrameworkCore.SqlServer (5.0.10)

But when I try to upgrade the packages to 6.0.0 I am receiving a Nuget error of NU1202 for all three packages. Example of errors is:

Error NU1202 Package Microsoft.AspNetCore.Identity.EntityFrameworkCore 6.0.0 is not compatible with netstandard2.1 (.NETStandard,Version=v2.1). Package Microsoft.AspNetCore.Identity.EntityFrameworkCore 6.0.0 supports: net6.0 (.NETCoreApp,Version=v6.0)

Could the two 6.0.0-previews be causing an issue? Can someone please help with the upgrade issue? I must be missing something that I should be changing or doing! Thanks...

Orgbrat

Orgbrat
  • 331
  • 6
  • 20
  • 3
    There is no .NET Standard version compatible with .NET 6. If you need .NET 6 functionality from within your library, your library has to be .NET 6 too. (Of course, you can still use a .NET Standard library in .NET 6, as long as it only uses .NET Standard functionality.) – Jeroen Mostert Nov 18 '21 at 15:25

1 Answers1

3

See Plan for Entity Framework Core 6.0:

EF Core 6.0 requires .NET 6. EF Core 6.0 does not target any .NET Standard version; for more information see the future of .NET Standard.

You'll need to upgrade your library to target net6.0 in order to use Entity Framework 6:

<TargetFramework>net6.0</TargetFramework>

This also means that projects consuming this library will need to target .NET 6.

CodeCaster
  • 147,647
  • 23
  • 218
  • 272
  • 1
    Thanks for the quick reply and moving all projects to net6.0 was the answer. Again thanks you folks saved me some headaches. – Orgbrat Nov 18 '21 at 15:51