As Microsoft will no longer provide servicing updates or technical support. NET Core 3.1., It is good to Migrate the application from .NET 3.1 to .NET 6.
prerequisite
Visual Studio 2022
- Open the Project file and update Target Framework
or
Right Click on Project -> Properties → Select Target Framework
2. Update Package References
<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>
3. Delete bin and Obj Folder
This will help to clear nuget cache, After that Build and Run the Application
4. While Deploying your application you need to update Docker File to use .NET 6
- docker pull mcr.microsoft.com/dotnet/core/aspnet:3.1
+ docker pull mcr.microsoft.com/dotnet/aspnet:6.0
This is Microsoft official reference https://learn.microsoft.com/en-us/aspnet/core/migration/31-to-60?view=aspnetcore-7.0&tabs=visual-studio