Upgrading from ASP.NET Core 3.1 to 5.0 (Preview 1) Header

Upgrading from ASP.NET Core 3.1 to 5.0 (Preview 1)

In this post, I want to take a look at the steps required to upgrade some projects to the first preview of .NET 5 and ASP.NET Core 5.0. Both were released yesterday (16th March 2020) and are the first public previews we have available for these future versions. The .NET 5 roadmap has these scheduled for a final release in November, this year.

.NET Release Schedule

I’ve also produced a video hosted on YouTube explaining this process in detail. I’ve included a link to the video at the bottom of this post.

Before following along with these steps on your development PC and for existing projects, please let me caution you on two crucial points.

  1. This is the first preview of .NET 5 and contains very little in the way of notable features. The products contain some initial bug fixes which can be viewed in the release notes. At this point, other than curiosity, I’d suggest there’s no real need to grab these bits.
  2. Planning further ahead; .NET 5.0 is not going to be an LTS (Long Term Support) release. As such, choosing it for upgrades to existing .NET Core projects needs a little extra consideration. When deciding upon using an LTS release, you may require more regular updates to stay on a supported product.

Preparing Your Development Machine

The first steps I took involved installing a couple of updates on my machine.

Install the .NET 5 SDK and Runtime

First, I installed the preview 1 SDK from the Microsoft .NET 5 download page.

Installation windows for .NET 5 preview 1 SDK (5.0.100-preview.1.20155.7)

The steps for that are pretty clear and take only a few minutes. After installation, I can confirm the new versions appear in my PC by running the dotnet --info command.

Output of dotnet --info command showing the inclusion of .NET 5 preview 1 SDK and runtimes.

Install VS 2019 16.6 Preview 1

The Microsoft preview release information recommends using Visual Studio 16.6 (preview 1) for development of .NET 5 projects.

You can download and install the preview from the Visual Studio 2019 Preview Release Notes page.

During installation, I choose the “ASP.NET and web development” and “.NET Core cross-platform development” workloads.

Workload selection window of the Visual Studio 16.6 preview installation

After installation, I now have the latest 16.5.0 general availability version and the 16.6 preview 1 version of Visual Studio installed side-by-side.

Visual Studio Installer after 16.6 preview version installation

With the pre-requisites installed, the next step was to attempt an upgrade for an existing .NET 3.1 solution. I choose to use my TennisBookings sample application which I have evolved for use with my Pluralsight courses. This solution includes several projects, and for this upgrade test, I chose to upgrade an MVC web application and an ASP.NET Core web API which it depends on. As I’ll cover, I also had to update a unit test project as well.

Upgrading the API Project

My web API project is currently using ASP.NET Core 3.1 and includes a simple controller-based endpoint which provides weather forecast data. The upgrade for this service was straightforward and required a small change to the SDK project file (csproj).

Here’s is the file before the upgrade:

And here it is after:

The only necessary change, in this case, was to change the TargetFramework value from netcoreapp3.1 to netcoreapp5.0.

Upgrading the Main Web Application

Next up for the upgrade to .NET 5 was the web application. This project uses controllers and Razor pages to render the UI. It uses Entity Framework Core for data access to a SQL Server database and it makes a HTTP call to the weather forecast API to load some data for its homepage.

The changes to this project were again, limited to the SDK project file.

Here’s is the file before the upgrade:

And here it is after:

As with the API project, my first change was to set the Target Framework to netcoreapp5.0.

There are a few other changes required in this more complex application since it references some extra packages.

As per the guidance in the Microsoft blog post, I first updated all package references starting with “Microsoft.AspNetCore” to version “5.0.0-preview.1.20124.5”.

I checked the Entity Framework Core 5 blog post and confirmed that the correct version for the “Microsoft.EntityFrameworkCore.*” packages is version “5.0.0-preview.2.20120.8”.

I took the opportunity to update some third party dependencies to the latest releases. This wasn’t required but is a practice I tend to follow during significant upgrades.

With that, I was ready to build the web application and weather API projects. I ran them both and confirmed they were working by loading the home page, which worked as expected and included the weather forecast data retrieved from the API. I also checked that I could log in to the site as an admin, which validated that the database connectivity was working as expected. Excellent, job done… nearly!

The tennis booking ASP.NET Core web application homepage after its upgrade to ASP.NET Core 5.

Upgrading the Unit Test Project

The final project I needed to work on was a unit test project which references and tests code from the web application project.

Currently, a build of my entire solution resulted in two errors.

  • NU1201: Project TennisBookings.Web is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Project TennisBookings.Web supports: netcoreapp5.0 (.NETCoreApp,Version=v5.0)
  • Project ‘..\..\src\TennisBookings.Web\TennisBookings.Web.csproj’ targets ‘netcoreapp5.0’. It cannot be referenced by a project that targets ‘.NETCoreApp,Version=v3.1’.

The errors are pretty clear; my unit test project required an upgrade to .NET 5 also.

Here’s the original SDK project file for the unit test project.

On line 19, it references the TennisBookings.Web project.

After upgrading, the update project file was as follows:

The only necessary change to get this compiling was to again change the Target Framework to netcoreapp5.0, to align with the web project it references. I took the opportunity to also update to the latest release of the Microsoft.NET.Test.Sdk.

I found at least for now (and I’ve not dug into it too deeply) that the unit test project builds perfectly fine, but the Visual Studio Test Explorer refuses to run the tests. It seems to be locating the wrong framework version. Curiously, running the unit tests from the command line using dotnet test seem to work without an issue. 

Output from dotnet test command run using the .NET CLI showing successful tests.

Update (19th March 2020): After feedback from the Visual Studio team I now understand my error which caused the tests in Visual Studio to not run. I’ll provide a complete post soon, but in short, the .NET SDK I downloaded only included the x64 SDK, runtime and packages. However, my test project was configured to run under x86. As a result, the SDK was looking for the x86 packages. After changing my project to run the tests using auto (which defaults to x64), they ran just fine!


This post demonstrated a quick test of the first public preview for .NET 5 for me. The test was very smooth, with no notable breaking changes affecting me. As I stated at the start of this post, there’s no compelling reason for you to use preview 1 for your applications. I’d certainly suggest it’s too early for production use. The product teams will be making many changes over the coming months, and I’m sure we’ll receive more feature-rich previews along the way. I’ll follow those previews as they become available.

YouTube Content

Below is a 12 minute YouTube video which demonstrates the steps from this blog post to complete the upgrade to ASP.NET Core 5.0 preview 1.

Have you enjoyed this post and found it useful? If so, please consider supporting me:

Buy me a coffeeBuy me a coffee Donate with PayPal

Steve Gordon

Steve Gordon is a Pluralsight author, 6x Microsoft MVP, and a .NET engineer at Elastic where he maintains the .NET APM agent and related libraries. Steve is passionate about community and all things .NET related, having worked with ASP.NET for over 21 years. Steve enjoys sharing his knowledge through his blog, in videos and by presenting talks at user groups and conferences. Steve is excited to participate in the active .NET community and founded .NET South East, a .NET Meetup group based in Brighton. He enjoys contributing to and maintaining OSS projects. You can find Steve on most social media platforms as @stevejgordon

Leave a Reply

Your email address will not be published. Required fields are marked *