Home > database >  How-to fix .NET 5.0 to 6.0 migration error
How-to fix .NET 5.0 to 6.0 migration error

Time:11-19

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

CodePudding user response:

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.

  • Related