How To Migrate From .NET Core 3.1 To .NET 6.0
How To Migrate From .NET Core 3.1 To .NET 6.0
NET
6.0
Satya Karki
Updated date May 06, 2022
20.7k
1
6
facebook
o
o
o
o
Expand
Introduction
.Net 6 is an LTS (Long Tern Support) Version. It will be supported for three years. It is the latest
long-term support release. The previous version, .Net Core 3.1 support will be finalized in
December 2022, and support for .Net 5 will be ended May 2022. This article describes how to
upgrade the solution from .Net Core 3.1 to .NET 6.0 with an example of Console application
and .Net Core 3.1 class library project. Upgrading console applications and class library project is
almost similar. However, there is some difference between Upgrading ASP.NET Core Web app.
Prerequisites
Visual Studio 2022
Step 1 - Upgrade the Target Framework
Right-click on the project then go to properties and change the target.
Then select the target framework to .NET 6.0 as depicted below and save it.
Alternatively from project.csproj file you can change the target Framework from netcore3.1 to net
6.0 as shown below.
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
C#
Copy
<ItemGroup>
- <PackageReference Include="Microsoft.AspNetCore.JsonPatch"
Version="3.1.6" />
- <PackageReference Include="Microsoft.EntityFrameworkCore.Tools"
Version="3.1.6" />
- <PackageReference Include="Microsoft.Extensions.Caching.Abstractions"
Version="3.1.6" />
- <PackageReference Include="System.Net.Http.Json" Version="3.2.1" />
+ <PackageReference Include="Microsoft.AspNetCore.JsonPatch"
Version="6.0.0" />
+ <PackageReference Include="Microsoft.EntityFrameworkCore.Tools"
Version="6.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Caching.Abstractions"
Version="6.0.0" />
+ <PackageReference Include="System.Net.Http.Json" Version="6.0.0" />
</ItemGroup>
C#
Copy
The above three steps are required to follow to upgrade the class library and console application
to migrate from .NET Core 3.1 to .NET 6.0.
On the other hand, to update the Asp.NET Core 3.1 and Blazor application you need to follow
more steps in addition to the above three.
Following are some changes you need to consider for upgrading ASP.NET Core 3.1 web
application to .NET6