How to migrate ASP.NET core 3.1 to ASP.NET 6.0

Views: 4841
Comments: 2
Like/Unlike: 2
Posted On: 28-Jun-2022 23:52 

Share:   fb twitter linkedin
144 Points
12 Posts

ASP.NET 6.0 is a Long Term Support Version (supported for three years). 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 explains how to update an existing ASP.NET Core 3.1 project to ASP.NET Core 6.0. 


  1. Visual Studio 2022
  2. .Net 6.0 SDK

Following are the steps to migrate ASP.NET core 3.1 to ASP.NET 6.0:

  1. Update the target framework:

    Open .csproj file in edit mode and change TargetFramework to .net6.0
    <Project Sdk="Microsoft.NET.Sdk.Web">
    -    <TargetFramework>netcoreapp3.1</TargetFramework>
    +    <TargetFramework>net6.0</TargetFramework>
  2. Upgrade package to 6.0 if required like:

    -    <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" />
  3. Delete bin and obj folders and clear cache: 

    We may need to delete the bin and obj folders. Run dotnet nuget locals --clear all to clear the NuGet package cache.
    dotnet nuget locals --clear all
  4. Update Docker images:

    - docker pull
    + docker pull


    -FROM AS base
    +FROM AS base
    -FROM AS build
    +FROM AS build
  5. Minimal hosting model (OPTIONAL):

     The minimal hosting model unifies Startup.cs and Program.cs into a single Program.cs file. ConfigureServices and Configure are no longer used. Apps migrating from ASP.NET Core 3.1 to 6.0 don't need to use the minimal hosting model, using Startup and the Generic Host used by the ASP.NET Core 3.1 templates is fully supported. To use Startup with the new minimal hosting model, see

  6. Upgrade to common package which is build on .NET 6.0

  7. Build and run the project in VS 2022 and verify the bin folder, it should contain only .net6.0 libraries.






Thanks for sharing useful code.

Mithilesh Tata
 Log In to Chat