From 7ce2276f92459d87e1fa6198fb892b5a8bf89221 Mon Sep 17 00:00:00 2001 From: Arthur Vickers Date: Mon, 25 Mar 2024 17:50:03 +0000 Subject: [PATCH] Add breaking change for removal of Cosmos sync support --- .../core/learn-more/community-standups.md | 4 +- .../ef-core-9.0/breaking-changes.md | 41 ++++++++++++++++--- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/entity-framework/core/learn-more/community-standups.md b/entity-framework/core/learn-more/community-standups.md index 82787e0968..fce28af4ff 100644 --- a/entity-framework/core/learn-more/community-standups.md +++ b/entity-framework/core/learn-more/community-standups.md @@ -110,8 +110,8 @@ Featuring: Links: -- Product: [Hot Chocolate for GraphQL](https://chillicream.com/docs/hotchocolate/v14) -- Docs: [Hot Chocolate and Entity Framework Core](https://chillicream.com/docs/hotchocolate/v14/integrations/entity-framework) +- Product: [Hot Chocolate for GraphQL](https://chillicream.com/docs/hotchocolate) +- Docs: [Hot Chocolate and Entity Framework Core](https://chillicream.com/docs/hotchocolate/integrations/entity-framework) diff --git a/entity-framework/core/what-is-new/ef-core-9.0/breaking-changes.md b/entity-framework/core/what-is-new/ef-core-9.0/breaking-changes.md index da8ea2c92d..cb398be1ed 100644 --- a/entity-framework/core/what-is-new/ef-core-9.0/breaking-changes.md +++ b/entity-framework/core/what-is-new/ef-core-9.0/breaking-changes.md @@ -2,7 +2,7 @@ title: Breaking changes in EF Core 9 (EF9) - EF Core description: List of breaking changes introduced in Entity Framework Core 9 (EF9) author: ajcvickers -ms.date: 11/29/2023 +ms.date: 03/25/2024 uid: core/what-is-new/ef-core-9.0/breaking-changes --- @@ -20,8 +20,39 @@ EF Core 9 targets .NET 8. This means that existing applications that target .NET ## Summary -| **Breaking change** | **Impact** | -|:--------------------|------------| -| | | +| **Breaking change** | **Impact** | +|:-----------------------------------------------------------------------------------|------------| +| [Sync I/O via the Azure Cosmos DB provider is no longer supported](#cosmos-nosync) | Medium | -## High-impact changes +## Medium-impact changes + + + +### Sync I/O via the Azure Cosmos DB provider is no longer supported + +[Tracking Issue #32563](https://github.com/dotnet/efcore/issues/32563) + +#### Old behavior + +Previously, calling synchronous methods like `ToList` or `SaveChanges` would cause EF Core to block synchronously using `.GetAwaiter().GetResult()` when executing async calls against the Azure Cosmos DB SDK. This can result in deadlock. + +#### New behavior + +Starting with EF Core 9.0, EF now throws by default when attempting to use synchronous I/O. The exception message is, "Azure Cosmos DB does not support synchronous I/O. Make sure to use and correctly await only async methods when using Entity Framework Core to access Azure Cosmos DB. See [https://aka.ms/ef-cosmos-nosync](https://aka.ms/ef-cosmos-nosync) for more information." + +#### Why + +Synchronous blocking on asynchronous methods can result in deadlock, and the Azure Cosmos DB SDK only supports async methods. + +#### Mitigations + +In EF Core 9.0, the error can be suppressed with: + +```csharp +protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) +{ + optionsBuilder.ConfigureWarnings(w => w.Ignore(CosmosEventId.SyncNotSupported)); +} +``` + +That being said, applications should stop using sync APIs with Azure Cosmos DB since this is not supported by the Azure Cosmos DB SDK. The ability to suppress the exception will be removed in a future release of EF Core, after which the only option will be to use async APIs.