- Where and How to Start?
- Steps to Migrate from .NET Core 3.1 to .NET 8
- Step 1 – Analyze Your Current Application
- Step 2 – Install .NET 8 SDK
- Step 3 – Update the Project File
- Step 4 – Update NuGet Packages
- Step 5 – Migrate Code to Address Breaking Changes
- Step 6 – Test and Debug the Application
- Step 7 – Deploy the Upgraded Application
- Useful Links
- Checklist for Migration from .NET Core 3.1 to .NET 8
- Pre-Migration Analysis
- Environment Setup
- Upgrade the Project
- Code Refactoring & API Updates
- Testing & Debugging
- Deployment & Post-Migration Validation
.NET Core 3.1 is no longer supported. This puts the applications running on it at risk. Microsoft no longer provides updates, bug fixes or support. And a business might face security and compliance issues. It has become a prime target for cyberattacks. This can cause severe trouble for industries dealing with sensitive data. For example, finance, healthcare, and e-commerce.
Also, developers often can’t find help. They don’t have access to Microsoft support and documentation updates.
Upgrading to .NET 8 is essential to maintain secure and future-proof applications.
Where and How to Start?
Migrating from .NET Core 3.1 to .NET 8 brings multiple benefits to a business. But the process requires careful planning. First, you need to analyze your current application. During the analysis, identify dependencies, third-party libraries and potential breaking changes. Since .NET Core 3.1 reached end-of-life, a business should think about upgrading to enhance performance and security.
But before starting the migration, ensure that the development environment meets the requirements. For example, you need to install the latest .NET 8 SDK. Ensure you use the latest version of Visual Studio 2022, JetBrains Rider, or VS Code.
Use the tools for the migration process. You can use the .NET Upgrade Assistant from Microsoft. It automates code conversion and identifies breaking changes. To detect deprecated APIs and receive alternative recommendations, use .NET API Analyzer. For running tests, update your CI/CD pipeline to build with .NET 8.
Steps to Migrate from .NET Core 3.1 to .NET 8
Step 1 – Analyze Your Current Application
Before making any changes, first of all, back up your project. If something goes wrong, you can revert to the previous state.
Also, it is important to analyze your existing .NET Core 3.1 application. You should identify dependencies, third-party libraries and potential critical changes.
How to do that?
- Start by opening a terminal or command prompt in your project directory. Check the installed SDKs:
- List outdated dependencies:
- To check compatibility, run the .NET Portability Analyzer:
Step 2 – Install .NET 8 SDK
Download and install the latest .NET 8 SDK to enable project migration. To do that, visit .NET downloads and install the .NET 8 SDK. Verify installation:
It should return a version starting with 8.x.x.
Step 3 – Update the Project File
The next step is to change your project file to target .NET 8 instead of .NET Core 3.1. To do that, open your .csproj file and change the <TargetFramework> value:
| 123456789 | <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
</Project> |
And save the file.
Step 4 – Update NuGet Packages
Update NuGet packages. This will help you ensure that all dependencies are compatible with .NET 8. To do that, use the CLI:
Don’t forget to check for breaking changes in package documentation.
Step 5 – Migrate Code to Address Breaking Changes
At this stage, you need to refactor your code to accommodate breaking changes introduced in .NET 8. Check the official documentation on breaking changes. Update APIs and remove deprecated code. For example:
| 123456789 | // Old in .NET Core 3.1
IWebHostBuilder builder = WebHost.CreateDefaultBuilder(args);
// New in .NET 8
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build(); |
After changes, test your application. As a result, you receive no compilation errors due to removed or changed APIs. Also, the application behavior should remain consistent.
Step 6 – Test and Debug the Application
Run your application and verify that everything works as expected. To run unit tests, use this code:
And to start the application and check logs:
After that, fix any runtime errors or warnings.
Step 7 – Deploy the Upgraded Application
Finally, you can deploy the migrated application to a production environment. Publish the app:
After that, deploy to a server or cloud service. And monitor logs for issues.
Useful Links
To make your migration from .NET Core 3.1 to .NET 8 smoother, we’ve collected a list of resources that might help:
.NET Download Page to download the latest .NET 8 SDK: https://dotnet.microsoft.com/download
.NET 8 Release Notes – the overview of new features and improvements in .NET 8: https://learn.microsoft.com/en-us/dotnet/core/whats-new/dotnet-8
.NET Versions and Support Lifecycle – check the support timeline for different .NET versions: https://learn.microsoft.com/en-us/dotnet/core/releases-and-support
.NET Upgrade Assistant – a Microsoft tool for upgrading applications: https://learn.microsoft.com/en-us/dotnet/core/porting/upgrade-assistant-overview
Breaking Changes in .NET 8 – it is a list of API changes that might influence the migration process: https://learn.microsoft.com/en-us/dotnet/core/compatibility/
The guide on deploying .NET applications: https://learn.microsoft.com/en-us/dotnet/core/deploying/
Checklist for Migration from .NET Core 3.1 to .NET 8
We’ve prepared a checklist to help you ensure a smooth migration from .NET Core 3.1 to .NET 8:
Pre-Migration Analysis
- Back up your application
- Identify dependencies and third-party libraries
- Check for breaking changes in .NET 8
- Run .NET Portability Analyzer to assess compatibility
- Document any deprecated APIs or removed features
Environment Setup
- Install .NET 8 SDK
- Update IDE
- Verify installation using dotnet ––version
- Install the required OS and dependencies
Upgrade the Project
- Upgrade <TargetFramework> in .csproj to .NET 8
- Remove obsolete configuration files
- Upgrade all NuGet dependencies using:
Code Refactoring & API Updates
- Replace deprecated APIs with equivalents in .NET 8
- Migrate IHostBuilder and WebHostBuilder to WebApplication
- Update logging, DI configurations, and middleware as needed
- Modify EF Core queries if upgrading Entity Framework
Testing & Debugging
- Run dotnet build to ensure successful compilation
- Execute unit tests with dotnet test
- Fix any runtime issues
- Check logs for warnings and deprecation messages
Deployment & Post-Migration Validation
- To publish the application, use:
- Update CI/CD pipelines to use .NET 8
- Deploy to the production/staging environment
- Monitor logs and app performance
- Gather user feedback and validate functionality