I'm upgrading from .NET 5 to 6 (and ASP.NET Core / EF Core 5 to 6).
Is there a comprehensive migration "checklist" I can follow?
CodePudding user response:
General checklist for any version
1. Pre-upgrade
- If you're upgrading a non-trivial production system, ensure you have a few days to spare
- Make a list of all your third-party libraries (nugets), and visit their repos. Ensure each one supports the latest framework version - if not, then you 1) cannot upgrade yet, or 2) must find replacements for those not yet compatible with the latest framework.
2. Upgrade
- Checkout new git branch
- Run all tests: important to take a baseline before upgrading, to be able to compare before/after. Take note of failing tests, if any (so they can be ignored later).
- Review release notes
- Review official migration guides
- General: 3.1 -> 5.0, 5.0 -> 6.0
- Samples: 3.1/5.0 -> 6.0
- Review breaking changes
- C#: overview, v9, v10
- ASP.NET Core: 3.1 -> 5.0, 5.0 -> 6.0
- EF Core: v5, v6
- Update dependencies (in
Directory.Build.props
orMyProject.csproj
)- Update SDK if necessary
- Update framework:
<TargetFramework>net6.0</TargetFramework>
- Update language version (if necessary):
<LangVersion>10.0</LangVersion>
- Update Microsoft packages named
Microsoft.AspNetCore.*
andMicrosoft.Extensions.*
- Update other dependencies, only if necessary (to reduce this migration's complexity). Update libraries which have been updated for the new framework version, as well as those that must be updated, e.g. non-Microsoft database providers.
- Update relevant dotnet tools, if necessary (in
dotnet-tools.json
, or those installed globally)
- Handle breaking changes
- Fix broken code
- Fix broken tests; ignore failing tests which were already broken before the migration (fix them later)
- Remove obsolete workarounds. Find those workarounds that are no longer necessary due to changes/fixes in the latest framework. Typically those you've (hopefully) noted with something like
// workaround: will be fixed in v6
. - Add new Roslyn analysers to
.editorconfig
: v5, v6 - Rerun tests, and compare to baseline
- Update documentation
- Update relevant project documentation
- Search for and update version-specific links, if necessary, e.g. links to
docs.microsoft.com
often have a version number like&view=aspnetcore-5.0
when there could be behaviour changes between versions
- Commit the git branch
3. Post-upgrade
- Adopt new features, if necessary and/or desired. Most new framework features are optional, so only adopt them if you really want them.
- Perform tasks necessary to satisfy your continuous integration system, if appropriate.
Checklist for v6
3. Post-upgrade
- Adopt major new features, optional
- Refactor for global using directives
- Refactor for file-scoped namespaces
- Refactor for new minimal hosting model, by merging
Program.cs
andStartup.cs
- Refactor for minimal APIs