Easily Migrate your ASP.NET Core 3.1 Solution Projects to the latest in ASP.NET 6.0
Table of Contents
In this article, I am going to show the process of migrating an ASP.NET Core 3.1 Web API CRUD project to the latest and current ASP.NET 6.0.
YouTube Version:
https://youtu.be/Hth2P3KHiEQ
Pre-requisites:
Since ASP.NET 6.0 requires Visual Studio 2022, you need to have Visual Studio 2022 installed on your machine. You can download Visual Studio 2022 Community version from the link above.
For this pupose, I shall clone my GitHub repository: https://github.com/krchome/WebAPIWithMVCClient_3.1
This repository contains the original solution with projects written in ASP.NET Core 3.1
The solution contains two projects :
- A Web API project that exposes Customer data and the related Orders to a particular Customer. The Web API uses a MS SQL and ADO.NET technology using stored procedures for all the CRUD operations
- An MVC project that consumes the data exposed by the Web API project
Clone the Repository
Since the purpose of this post is to show the migration pathway to ASP.NET 6.0, I shall not delve into the unnecessary details of creating the project that is already existing with the functionalities as I clone it from GitHub (Fig 1)

Copy the clone link and open File Explorer and browse to a folder of your choice and right click and click Git Bash Here :

On the Git Bash Window, issue the command below
git clone (repo link as in Fig 3) below:

Once the project is cloned, expand the Solution folder and open it with Visual Studio 2022 Community version (Fig 4)

The Solution Explorer Window looks like this (Fig 5)

Update Target Framework
We now update the target framework in both the project files (.csproj) by clicking them to open them in the edit mode in VS 2022 as below:

Change TargetFramework to net6.0 (Fig. 7)

Do the same for the MVC project (Fig 8 & 9)


Update Package References
In the project file, update each package to their latest reference’s Version attribute to 6.0.0 or later (if available). For third party packages (like Serilog) update them to their latest stable versions.
For example for the Web API, change the package references from the existing as in fig 10 :

to the following updated versions as below (Fig. 11)

For the MVC project, change the references from the existing as below (Fig 12):

to the following versions as in Fig. 13

Clear NuGet Package Cache
Run dotnet nuget locals –clear all to clear NuGet Package Cache for each of the two projects from the PM Console as follows:

Delete bin and obj folders
Next I deleted the bin and obj folders from the MVC project (in the Solution Explorer)
Minimal hosting model
The ASP.NET Core templates generate code using the new minimal hosting model. The minimal hosting model unifies Startup.cs and Program.cs into a single Program.cs file. ConfigureServices and Configure are no longer used.
However, 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. So now our migration from 3.1 to 6.0 is complete (if I don’t wish to go for the minimal hosting model as such and we are ready to test the solution.
Testing the migration (Without minimal hosting model)
I shall run the solution now after configuring the properties to start both the projects simultaneously as below. Right click the solution and in the menu click on Properties (Fig. 15)

On the Solution Property Pages Window (Fig. 16) click on Apply and OK button after configuring as follows (Fig 16):

Now click either Start (or Start Without Debugging Green Arrow) on top

will start both the projects and bring this screen (Web API project):

And the MVC Consume project window that is shown in the screen below:

If we click the click here link it will bring up the following screenshot (Fig. 19)

That’s it!! Our application is running perfectly after migrating to ASP.Net 6.0 . Now you can enjoy a cup of coffee.
Follow Me Here