9

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>
Matt W
  • 11,753
  • 25
  • 118
  • 215
  • 1
    I am using netstandard2.0 that works with any version net and net core. – Serge May 23 '22 at 13:08
  • 1
    netstandard2.1 is really only useful if you want to *prevent* the library from being used in a legacy .NETFramework solution. – Hans Passant May 23 '22 at 13:27
  • Yes, if you do not need any backward compatibility with .NET Core 3.1, that is the way to go. For more information about which TFM's to use nowadays, see [this link](https://www.rodyvansambeek.com/blog/net-standard-or-not-in-2023) – Rody Apr 23 '23 at 18:12

2 Answers2

4
- <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)

purnadika
  • 282
  • 2
  • 12
0

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.
  • 2
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 15 '22 at 12:43