Breaking changes in .NET 6

If you're migrating an app to .NET 6, the breaking changes listed here might affect you. Changes are grouped by technology area, such as ASP.NET Core or Windows Forms.

This article indicates whether each breaking change is binary compatible or source compatible:

  • Binary compatible - Existing binaries will load and execute successfully without recompilation, and the run-time behavior won't change.
  • Source compatible - Source code will compile successfully without changes when targeting the new runtime or using the new SDK or component.

ASP.NET Core

Title Binary compatible Source compatible
ActionResult<T> sets StatusCode to 200 ✔️
AddDataAnnotationsValidation method made obsolete ✔️
Assemblies removed from Microsoft.AspNetCore.App shared framework ✔️
Blazor: Parameter name changed in RequestImageFileAsync method ✔️
Blazor: WebEventDescriptor.EventArgsType property replaced
Blazor: Byte array interop ✔️
Changed MessagePack library in @microsoft/signalr-protocol-msgpack ✔️
ClientCertificate property doesn't trigger renegotiation for HttpSys ✔️
EndpointName metadata not set automatically ✔️
Identity: Default Bootstrap version of UI changed
Kestrel: Log message attributes changed ✔️
Microsoft.AspNetCore.Http.Features split ✔️
Middleware: HTTPS Redirection Middleware throws exception on ambiguous HTTPS ports ✔️
Middleware: New Use overload ✔️
Minimal API renames in RC 1
Minimal API renames in RC 2
MVC doesn't buffer IAsyncEnumerable types when using System.Text.Json ✔️
Nullable reference type annotations changed ✔️
Obsoleted and removed APIs ✔️
PreserveCompilationContext not configured by default ✔️
Razor: Compiler no longer produces a Views assembly ✔️
Razor: Logging ID changes ✔️
Razor: RazorEngine APIs marked obsolete ✔️
SignalR: Java Client updated to RxJava3 ✔️
TryParse and BindAsync methods are validated

Containers

Title Binary compatible Source compatible
Default console logger formatting in container images ✔️

For information on other breaking changes for containers in .NET 6, see .NET 6 Container Release Notes.

Core .NET libraries

Title Binary compatible Source compatible
API obsoletions with non-default diagnostic IDs ✔️
Changes to nullable reference type annotations ✔️
Conditional string evaluation in Debug methods ✔️
Environment.ProcessorCount behavior on Windows ✔️
EventSource callback behavior ✔️ ✔️
File.Replace on Unix throws exceptions to match Windows ✔️
FileStream locks files with shared lock on Unix ✔️
FileStream no longer synchronizes file offset with OS
FileStream.Position updates after ReadAsync or WriteAsync completes
New diagnostic IDs for obsoleted APIs ✔️
New System.Linq.Queryable method overloads ✔️
Older framework versions dropped from package ✔️
Parameter names changed ✔️
Parameter names in Stream-derived types ✔️
Partial and zero-byte reads in DeflateStream, GZipStream, and CryptoStream ✔️
Set timestamp on read-only file on Windows ✔️
Standard numeric format parsing precision ✔️
Static abstract members in interfaces ✔️
StringBuilder.Append overloads and evaluation order ✔️
Strong-name APIs throw PlatformNotSupportedException ✔️
System.Drawing.Common only supported on Windows
System.Security.SecurityContext is marked obsolete ✔️
Task.FromResult may return singleton ✔️
Unhandled exceptions from a BackgroundService ✔️

Cryptography

Title Binary compatible Source compatible
CreateEncryptor methods throw exception for incorrect feedback size ✔️

Deployment

Title Binary compatible Source compatible
x86 host path on 64-bit Windows ✔️ ✔️

Entity Framework Core

Breaking changes in EF Core 6

Extensions

Title Binary compatible Source compatible
AddProvider checks for non-null provider ✔️
FileConfigurationProvider.Load throws InvalidDataException ✔️
Repeated XML elements include index ✔️
Resolving disposed ServiceProvider throws exception ✔️

Globalization

Title Binary compatible Source compatible
Culture creation and case mapping in globalization-invariant mode

Interop

Title Binary compatible Source compatible
Static abstract members in interfaces ✔️

JIT compiler

Title Binary compatible Source compatible
Coerce call arguments according to ECMA-335 ✔️ ✔️

Networking

Title Binary compatible Source compatible
Port removed from SPN for Kerberos and Negotiate ✔️
WebRequest, WebClient, and ServicePoint are obsolete ✔️

SDK

Title Binary compatible Source compatible
-p option for dotnet run is deprecated ✔️
C# code in templates not supported by earlier versions ✔️ ✔️
EditorConfig files implicitly included ✔️
Generate apphost for macOS ✔️
Generate error for duplicate files in publish output ✔️
GetTargetFrameworkProperties and GetNearestTargetFramework removed from ProjectReference protocol ✔️
Install location for x64 emulated on Arm64 ✔️
MSBuild no longer supports calling GetType()
.NET can't be installed to custom location ✔️ ✔️
OutputType not automatically set to WinExe ✔️
Publish ReadyToRun with --no-restore requires changes ✔️
runtimeconfig.dev.json file not generated ✔️
RuntimeIdentifier warning if self-contained is unspecified ✔️
Tool manifests in root folder ✔️ ✔️
Version requirements for .NET 6 SDK ✔️ ✔️
.version file includes build version ✔️ ✔️
Write reference assemblies to IntermediateOutputPath ✔️

Serialization

Title Binary compatible Source compatible
DataContractSerializer retains sign when deserializing -0 ✔️
Default serialization format for TimeSpan ✔️
IAsyncEnumerable serialization ✔️
JSON source-generation API refactoring ✔️
JsonNumberHandlingAttribute on collection properties ✔️
New JsonSerializer source generator overloads ✔️

Windows Forms

Title Binary compatible Source compatible
C# templates use application bootstrap ✔️
Selected TableLayoutSettings properties throw InvalidEnumArgumentException ✔️
DataGridView-related APIs now throw InvalidOperationException ✔️
ListViewGroupCollection methods throw new InvalidOperationException ✔️
NotifyIcon.Text maximum text length increased ✔️
ScaleControl called only when needed ✔️
Some APIs throw ArgumentNullException ✔️
TreeNodeCollection.Item throws exception if node is assigned elsewhere ✔️

XML and XSLT

Title Binary compatible Source compatible
XNodeReader.GetAttribute behavior for invalid index ✔️

See also