Announcing Entity Framework Core 6.0 Preview 2

Jeremy Likness

Today, the Entity Framework Core team announces the second preview release of EF Core 6.0. This release includes changes to handling the synchronization context when SaveChangesAsync is called, smoother integration with System.Linq.Async, updates to string concatenation and improvements to free text search.


  • EF Core 6.0 currently targets .NET 5. This will likely be updated to .NET 6 as we near the release. EF Core 6.0 does not target any .NET Standard version; for more information see the future of .NET Standard.
  • EF Core 6.0 will not run on .NET Framework.

How to get EF Core 6.0 previews

EF Core is distributed exclusively as a set of NuGet packages. For example, to add the SQL Server provider to your project, you can use the following command using the dotnet CLI:

dotnet add package Microsoft.EntityFrameworkCore.SqlServer --prerelease

This following table links to the preview 2 versions of the EF Core packages and describes what they are used for.

Package Purpose
Microsoft.EntityFrameworkCore The main EF Core package that is independent of specific database providers
Microsoft.EntityFrameworkCore.SqlServer Database provider for Microsoft SQL Server and SQL Azure
Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite SQL Server support for spatial types
Microsoft.EntityFrameworkCore.Sqlite Database provider for SQLite that includes the native binary for the database engine
Microsoft.EntityFrameworkCore.Sqlite.Core Database provider for SQLite without a packaged native binary
Microsoft.EntityFrameworkCore.Sqlite.NetTopologySuite SQLite support for spatial types
Microsoft.EntityFrameworkCore.Cosmos Database provider for Azure Cosmos DB
Microsoft.EntityFrameworkCore.InMemory The in-memory database provider
Microsoft.EntityFrameworkCore.Tools EF Core PowerShell commands for the Visual Studio Package Manager Console; use this to integrate tools like scaffolding and migrations with Visual Studio
Microsoft.EntityFrameworkCore.Design Shared design-time components for EF Core tools
Microsoft.EntityFrameworkCore.Proxies Lazy-loading and change-tracking proxies
Microsoft.EntityFrameworkCore.Abstractions Decoupled EF Core abstractions; use this for features like extended data annotations defined by EF Core
Microsoft.EntityFrameworkCore.Relational Shared EF Core components for relational database providers
Microsoft.EntityFrameworkCore.Analyzers C# analyzers for EF Core

We also published the 6.0 preview 2 release of the Microsoft.Data.Sqlite.Core provider for ADO.NET.

Installing the EF Core Command Line Interface (CLI)

As with EF Core 3.0 and 3.1, the EF Core CLI is no longer included in the .NET Core SDK. Before you can execute EF Core migration or scaffolding commands, you’ll have to install this package as either a global or local tool.

To install the preview tool globally, first uninstall any existing version with:

dotnet tool uninstall --global dotnet-ef

Then install with:

dotnet tool install --global dotnet-ef --version 6.0.0-preview.2.21154.2

It’s possible to use this new version of the EF Core CLI with projects that use older versions of the EF Core runtime.

What’s New in EF Core 6 Preview 2

We maintain documentation covering new features introduced into each preview.

Some of the highlights from preview 2 are called out below. This preview also includes several bug fixes.

TIP You can run and debug into all the preview 2 samples shown below by downloading the sample code from GitHub.

NOTE The following fix did not make it into Preview 2: #24251.

Preserve synchronization context in SaveChangesAsync

GitHub Issue: #23971.

We changed the EF Core code in the 5.0 release to set System.Threading.Tasks.Task.ConfigureAwait to false in all places where we await async code. This is generally a better choice for EF Core usage. However, Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync is a special case because EF Core will set generated values into tracked entities after the async database operation is complete. These changes may then trigger notifications which, for example, may have to run on the U.I. thread. Therefore, we are reverting this change in EF Core 6.0 for the Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync method only.

Translate String.Concat with multiple arguments

GitHub Issue: #23859. This feature was contributed by @wmeints.

Starting with EF Core 6.0, calls to System.String.Concat with multiple arguments are now translated to SQL. For example, the following query:

var shards = context.Shards
  .Where(e => string.Concat(e.Token1, e.Token2, e.Token3) != e.TokensProcessed).ToList();

Will be translated to the following SQL when using SQL Server:

SELECT [s].[Id], [s].[Token1], [s].[Token2], [s].[Token3], [s].[TokensProcessed]
FROM [Shards] AS [s]
WHERE ((COALESCE([s].[Token1], N'') + (COALESCE([s].[Token2], N'') + COALESCE([s].[Token3], N''))) <> [s].[TokensProcessed]) OR [s].[TokensProcessed] IS NULL

Smoother integration with System.Linq.Async

GitHub Issue: #24041.

The System.Linq.Async package adds client-side async LINQ processing. Using this package with previous versions of EF Core was cumbersome due to a namespace clash for the async LINQ methods. In EF Core 6.0 we have taken advantage of C# pattern matching for System.Collections.Generic.IAsyncEnumerable such that the exposed EF Core Microsoft.EntityFrameworkCore.DbSet does not need to implement the interface directly.

Note that most applications do not need to use System.Linq.Async since EF Core queries are usually fully translated on the server.

GitHub Issue: #23921.

In EF Core 6.0, we have relaxed the parameter requirements for Microsoft.EntityFrameworkCore.SqlServerDbFunctionsExtensions.FreeText(Microsoft.EntityFrameworkCore.DbFunctions,System.String,System.String) and Microsoft.EntityFrameworkCore.SqlServerDbFunctionsExtensions.Contains. This allows these functions to be used with binary columns, or with columns mapped using a value converter. For example, consider an entity type with a Name property defined as a value object:

public class Customer
  public int Id { get; set; }

  public Name Name{ get; set; }

public class Name
  public string First { get; set; }
  public string MiddleInitial { get; set; }
  public string Last { get; set; }

This is mapped to JSON in the database:

  .Property(e => e.Name)
    v => JsonSerializer.Serialize(v, null),
    v => JsonSerializer.Deserialize<Name>(v, null));

A query can now be executed using Contains or FreeText even though the type of the property is Name not string. For example:

var result = context.Customers.Where(e => EF.Functions.Contains(e.Name, "Martin")).ToList();

This generates the following SQL, when using SQL Server:

SELECT [c].[Id], [c].[Name]
FROM [Customers] AS [c]
WHERE CONTAINS([c].[Name], N'Martin')

Daily builds

EF Core previews are aligned with .NET 6 previews. These previews tend to lag behind the latest work on EF Core. Consider using the daily builds instead to get the most up-to-date EF Core features and bug fixes.

As with the previews, the daily builds require .NET 5.

The EF Core Community Standup

The EF Core team is now live streaming every other Wednesday at 10am Pacific Time, 1pm Eastern Time, or 17:00 UTC. Join the stream to ask questions about the EF Core topic of your choice, including the latest preview release.

Documentation and Feedback

The starting point for all EF Core documentation is

Please file issues found and any other feedback on the dotnet/efcore GitHub repo.

The following short links are provided for easy reference and access.

EF Core Community Standup Playlist:

Main documentation:

Issues and feature requests for EF Core:

Entity Framework Roadmap:

Thank you from the team

A big thank you from the EF team to everyone who has used EF over the years!

ajcvickers Arthur Vickers AndriySvyryd Andriy Svyryd Brice Lambson JeremyLikness Jeremy Likness
maumar Maurycy Markowski roji Shay Rojansky smitpatel Smit Patel

Thank you to our contributors!

We are grateful to our amazing community of contributors. Our success is founded upon the shoulders of your efforts and feedback. If you are interested in contributing but not sure how or would like help, please reach out to us! We want to help you succeed. We would like to publicly acknowledge and thank these contributors for investing in the success of EF Core 6.0.

Ali-YousefiTelori AndrewKitu ardalis CaringDev
#1, #2 #1 #1 #1, #2
carlreinke cgrimes01 cincuranet dan-giddins
#1, #2 #1 #1 #1
dennisseders DickBaker ErikEJ fagnercarvalho
#1, #2, #3, #4, #5, #6 #1 #1, #2, #3, #4, #5, #6, #7, #8 #1, #2
filipnavara garyng Geoff1900 gfoidl
#1, #2 #1, #2, #3 #1 #1, #2
Giorgi GitHubPang gurustron hez2010
#1, #2, #3, #4 #1 #1 #1, #2
HSchwichtenberg jantlee joakimriedel joaopgrassi
#1 #1 #1, #2 #1, #2
josemiltonsampaio KaloyanIT khalidabuhakmeh khellang
#1 #1, #2, #3, #4 #1, #2 #1
koenbeuk kotpal leonardoporro Marusyk
#1 #1 #1 #1, #2, #3, #4, #5, #6, #7, #8
MaxG117 mefateah meggima mrlife
#1 #1 #1, #2 #1
msawczyn MSDN-WhiteKnight natashanikolic nmichels
#1 #1 #1 #1, #2
nschonni Oxyrus pkellner ralmsdeveloper
#1, #2, #3, #4 #1 #1 #1, #2
RaymondHuy Shirasho SimonCropp the-wazz
#1, #2, #3, #4, #5, #6, #7, #8 #1 #1, #2 #1, #2
tkp1n Tomkaa umitkavala vincent1405
#1, #2 #1, #2 #1, #2, #3, #4 #1, #2
wmeints yesmey
#1, #2 #1, #2, #3, #4


Discussion is closed.

Feedback usabilla icon