AspNetCore.Docs/aspnetcore/migration/50-to-60.md

2.8 KiB

title author description ms.author ms.date no-loc uid
Migrate from ASP.NET Core 5.0 to 6.0 scottaddie Learn how to migrate an ASP.NET Core 5.0 project to ASP.NET Core 6.0. scaddie 03/15/2021
appsettings.json
ASP.NET Core Identity
cookie
Cookie
Blazor
Blazor Server
Blazor WebAssembly
Identity
Let's Encrypt
Razor
SignalR
migration/50-to-60

Migrate from ASP.NET Core 5.0 to 6.0

This article explains how to update an existing ASP.NET Core 5.0 project to ASP.NET Core 6.0.

Prerequisites

Visual Studio

[!INCLUDE]

Visual Studio Code

[!INCLUDE]

Visual Studio for Mac

[!INCLUDE]


Update .NET SDK version in global.json

If you rely upon a global.json file to target a specific .NET SDK version, update the version property to the .NET 6.0 SDK version that's installed. For example:

{
  "sdk": {
-    "version": "5.0.100"
+    "version": "6.0.100-preview.2.21155.3"
  }
}

Update the target framework

Update the project file's Target Framework Moniker (TFM) to net6.0:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
-    <TargetFramework>net5.0</TargetFramework>
+    <TargetFramework>net6.0</TargetFramework>
  </PropertyGroup>

</Project>

Update package references

In the project file, update each Microsoft.AspNetCore.* and Microsoft.Extensions.* package reference's Version attribute to 6.0.0 or later. For example:

<ItemGroup>
-    <PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="5.0.3" />
-    <PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="5.0.0" />
+    <PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="6.0.0-preview.2.*" />
+    <PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="6.0.0-preview.2.*" />
</ItemGroup>

Update Docker images

For apps using Docker, update your Dockerfile FROM statements and scripts. Use a base image that includes the ASP.NET Core 6.0 runtime. Consider the following docker pull command difference between ASP.NET Core 5.0 and 6.0:

- docker pull mcr.microsoft.com/dotnet/aspnet:5.0
+ docker pull mcr.microsoft.com/dotnet/aspnet:6.0

Review breaking changes

For breaking changes from .NET 5.0 to .NET 6.0, see Breaking changes for migration from version 5.0 to 6.0. ASP.NET Core and Entity Framework Core are also included in the list.