Migration from Asp.Net Core 5.0 to 6.0 — Real project

Alexandre Malavasi
5 min readNov 9, 2021

--

The purpose of this article is to share my personal experience in migrating a real production application from .NET 5 to .NET 6.

The project uses the following stack:

  • Asp.Net Core Web API
  • Vue JS front-end without any Razor Pages used in the project. The entire front-end is a Vue JS application
  • Entity Framework Core (Code First approach)
  • SQL Server Database

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, depending on the scenario, many projects aren’t migrated to a newer version.

I changed my mind in the last few 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, usually, are not 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.

Framework version change

After installing Visual Studio 2022, I created a branch for my project and opened it. The first thing that needs to be done is to change the target framework on the Properties of your projects in the solution:

As you can see, I changed from .NET 5.0 to .NET 6.0. In the following, I built the entire solution to see if it would produce issues. Considering the project was target to .NET 5 previously, I did not get any issues. If your project is based on .NET Core 3.1, I recommend migrating the project to .NET 5 first. I have an article teaching how to do the same processes for previous versions:

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 5. But, it might be different in your scenario. So, it is really important to analyze it before your own migration. First of all, I looked into my project to see how many packages I had that were compatible to be upgraded and I found that:

You can get the packages on the “Manage Nuget Packages” option or by opening the .csproj file for your project.

After upgrading all the possible packages from 5.0 to 6.0, I got the following results:

After upgrading the packages, I did not get any runtime issues running and navigating across the application.

Extra considerations

The migration for this project was really simple because I keep it updated constantly with the newer .NET version. The migration from .NET Core 2.2 to 3.1 was really complicated and from .NET Core 3.1 to .NET 5.0 as well. I’d say I’m taking all the benefits preventing postponing too much to upgrade the applications to the newest .NET version.

In your own scenario, it is recommended to evaluate if you don’t have packages that are not compatible with .NET 6 for some reason. Don’t forget to use a proper branch strategy in your Git Control system (Github, Azure DevOps, etc) and include proper tests and QA process after the upgrade. Even the project is building, the application may incur some random runtime issue that is not easy to catch. So, be careful :)

If you have several projects in the solution to upgrade, I recommend you to do that gradually: one project at a time, if it is possible.

Conclusion

I’m glad to announce that I have my first book published. It is a deep dive hands-on through the most common Design Patterns used in .NET applications. The book contains hundreds of code samples and explanations based on real-world scenarios. It also has many examples of Object-Oriented Programming, SOLID principles, and all the path to get yourself familiar with .NET 5 and C#. Check it out:

Twitter: https://twitter.com/alemalavasi
Linkedin: https://www.linkedin.com/in/alexandremalavasi/
Youtube: https://www.youtube.com/channel/UC-KFGgYiot1eA8QFqIgLmqA
Facebook: https://www.facebook.com/alexandre.malavasi.dev

References

--

--

Alexandre Malavasi

Microsoft MVP | MCP | MCTS | MCPD | ITIL | .NET | MBA | MTAC | Technical Leader | Consultant | .NET Developer