Migration From Asp.Net Core 3.1 to 5.0

The purpose of this article is to share my personal experience of migrating a medium complexity real project from Asp.Net Core 3.1 and Asp.Net Core 5.0.

The project uses the following stack:

  • Asp.Net Core Web API

At the beginning of my career, almost all the time I decided to postpone the upgrade of .NET projects under my responsibility to the newest version of the underlying technology. There are many factors that should be considered before migrating a system: costs, effort, complexity, business value, etc. Therefore, depends on the scenario, many projects aren’t migrated to a newer version.

I changed my mind in the last years, mainly after the launch of the first version of .NET Core. The first migrations from .NET Framework to .NET Core might be problematic for complex projects, but the migrations between .NET Core versions and to .NET 5 should not be that hard.

In the rest of the article, I’m going to demonstrate all the steps I made to migrate a real project, all the problems, and, of course, the solutions I’ve found and applied.

Visual Studio Update

The very first thing I did is to update Visual Studio 2019 to the latest version once the .NET 5.0 was officially launched yesterday (November, 11th).

Image for post

Usually, the update installs the newest .NET SDK as well. But, in case it is not, you need to install the .NET 5.0 SDK:

https://dotnet.microsoft.com/download/dotnet/thank-you/sdk-5.0.100-windows-x64-installer

Framework version change

Change the Target Framework to .NET 5.0:

Image for post

In order to make in how many issues you could have after this step is recommended rebuild the application and see how many issues will appear in compile time. In my case, no problems so far:

Image for post

Project file (.csproj)

The next step is to update the version of any package that has the target to .NET Core 3.1 version:

Image for post

Nuget package updates

Logically, the next step was to upgrade the rest of the packages used by the application to the newest possible version. In that context, I was using just third party libraries for Vue JS Middleware and native libraries of .NET Core. But, it might be different in your scenario. So, it is really important to analyze it before your own migration.

Image for post

Conclusion

After that, absolutely everything worked perfectly. No issues in Entity Framework, native JSON libraries, Startup.cs configurations.