Upgrading netstandard 2.0 class library to dotnet 6

Viewed 1406

I am upgrading a dotnet core 3.1 web app to dotnet core 6 which, of course, includes this change:

- <TargetFramework>netcoreapp3.1</TargetFramework>
+ <TargetFramework>net6.0</TargetFramework>

Now, with the class libraries, should I also replace the netstandard reference, too? Eg:

- <TargetFramework>netstandard2.1</TargetFramework>
+ <TargetFramework>net6.0</TargetFramework>
2 Answers
- <TargetFramework>netstandard2.1</TargetFramework>
+ <TargetFramework>net6.0</TargetFramework>

That works on mine. As Xinlin answer, just change it then update the nuget packages accordingly.

As my concern changing it was because I've to use dbcontext from the main app (netcore). By keeping it netstandard2.1 makes it fail to get the dbcontext (maybe because it uses different EFCore version, CMIIW)

I just completed migrating .NET Standard Library 2.1 to .NET 6 for my project.

  1. Changing this line of code in the project file. Change the target framework to net6.0
  2. Update all Nuget packages in the project to match the .Net Core 6 version.
Related