How to Migrate From Asp.Net Core 3.0 to 3.1

On the 3th of March 2020 .Net Core 3.0 reaches the end of support. It is not a long term supported version and if you did not upgrade to 3.1 yet, you definitely should wait no longer. We did the upgrade for the .Net User Group Bern site two months ago and had no problems at all.
Upgrading from 2.2. to 3.0 was a big challenge where Daniel and René had to do a lot of work.

 

Follow the official guide

Microsoft offers a guide for the upgrade that you can follow with ease. These are the main steps you need to do:

  1. Make sure that you have committed all your changes into your version control system
  2. Run a clean solution inside Visual Studio
  3. Open global.json and set “version” to “3.1.100” (see guide)
  4. In each project file, update the target framework from netcoreapp3.0 to netcoreapp3.1 (see guide)
  5. Update the package references for all Microsoft.AspNetCore.* packages to the version 3.1.0 (see guide)
  6. Rebuild your solution in Visual Studio
  7. Optional: If you use the RenderComponentAsync HTML helper, you can change that to the new Component Tag Helper (see guide)
  8. Run all your tests to check if your application still works as expected

If all those steps worked without a problem, you are done with the upgrade. I run in various compilation problems and fixed them by deleting all the bin folders.

 

SameSite cookie change

.Net Core 3.1 introduced some significant changes on how SameSite cookies work. This is in response to the changes in Google Chrome that are currently rolled out to all users. Run your application in Google Chrome and check if everything works. If not, the links provided in the guide should help you to make the necessary changes.

 

Conclusion

I was surprised how simple the upgrade from 3.0 to 3.1 was. If you follow along the guide and make sure that everything is committed to source control before you start, you should be able to do the upgrade in no time.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.