AspNetCore.Docs/aspnetcore/migration/80-90.md

78 lines
2.7 KiB
Markdown

---
title: Migrate from ASP.NET Core in .NET 8 to ASP.NET Core in .NET 9
author: rick-anderson
description: Learn how to migrate an ASP.NET Core in .NET 8 to ASP.NET Core in .NET 9
ms.author: riande
ms.date: 2/11/2024
uid: migration/80-to-90
---
<!-- New content should be added to ~/migration/includes/aspnetcore-9/includes/{FILE}.md files. This will help prevent merge conflicts in this file. -->
# Migrate from ASP.NET Core in .NET 8 to ASP.NET Core in .NET 9
This article explains how to update an ASP.NET Core in .NET 8 to ASP.NET Core in .NET 9.
## Prerequisites
# [Visual Studio](#tab/visual-studio)
[!INCLUDE[](~/includes/net-prereqs-vs-9.0.md)]
# [Visual Studio Code](#tab/visual-studio-code)
[!INCLUDE[](~/includes/net-prereqs-vsc-9.0.md)]
---
## Update the .NET SDK version in `global.json`
If you rely on a [`global.json`](/dotnet/core/tools/global-json) file to target a specific .NET Core SDK version, update the `version` property to the .NET 9.0 SDK version that's installed. For example:
```diff
{
"sdk": {
- "version": "8.0.100"
+ "version": "9.0.100"
}
}
```
## Update the target framework
Update the project file's [Target Framework Moniker (TFM)](/dotnet/standard/frameworks) to `net9.0`:
```diff
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
- <TargetFramework>net8.0</TargetFramework>
+ <TargetFramework>net9.0</TargetFramework>
</PropertyGroup>
</Project>
```
## Update package references
In the project file, update each [`Microsoft.AspNetCore.*`](https://www.nuget.org/packages?q=Microsoft.AspNetCore.*), [`Microsoft.EntityFrameworkCore.*`](https://www.nuget.org/packages?q=Microsoft.EntityFrameworkCore.*), [`Microsoft.Extensions.*`](https://www.nuget.org/packages?q=Microsoft.Extensions.*), and [`System.Net.Http.Json`](https://www.nuget.org/packages/System.Net.Http.Json) package reference's `Version` attribute to 9.0.0 or later. For example:
```diff
<ItemGroup>
- <PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="8.0.2" />
- <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.2" />
- <PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="8.0.0" />
- <PackageReference Include="System.Net.Http.Json" Version="8.0.0" />
+ <PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="9.0.0-preview.1.24081.5" />
+ <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0-preview.1.24081.2" />
+ <PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="9.0.0-preview.1.24080.9" />
+ <PackageReference Include="System.Net.Http.Json" Version="9.0.0-preview.1.24080.9" />
</ItemGroup>
```
## Blazor
[!INCLUDE[](~/migration/80-to-90/includes/blazor.md)]
## Additional resources