Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ This can be used to manage any aspect of your database, including:
* Triggers
* Views

In most cases, EF Core will automatically wrap each migration in its own transaction when applying migrations. Unfortunately, some migrations operations cannot be performed within a transaction in some databases; for these cases, you may opt out of the transaction by passing `suppressTransaction: true` to `migrationBuilder.Sql`.
In most cases, EF Core will automatically wrap each migration in its own transaction when applying migrations. Unfortunately, some migration operations cannot be performed within a transaction in some databases; for these cases, you may opt out of the transaction by passing `suppressTransaction: true` to `migrationBuilder.Sql`.

> [!NOTE]
> In EF Core 9, EF Core spans all pending migrations with a single transaction by default (this was reverted in EF Core 10). See [the breaking change note](xref:core/what-is-new/ef-core-9.0/breaking-changes#migrations-single-transaction) for details.

## Remove a migration

Expand Down
23 changes: 23 additions & 0 deletions entity-framework/core/what-is-new/ef-core-9.0/breaking-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ EF Core 9 targets .NET 8. This means that existing applications that target .NET
| [EF tools no longer support .NET Framework projects](#ef-tools-no-netfx) | Low |
| [`EF.Constant()` and `EF.Parameter()` no longer work inside compiled queries](#ef-constant-compiled) | Low |
| [Some `NoTrackingWithIdentityResolution` queries are now prohibited for JSON collections](#no-tracking-json) | Low |
| [All pending migrations are applied in a single transaction](#migrations-single-transaction) | Low |

## High-impact changes

Expand Down Expand Up @@ -450,6 +451,28 @@ var blogs = await context.Blogs
.ToListAsync();
```

<a name="migrations-single-transaction"></a>

### All pending migrations are applied in a single transaction

[Tracking Issue #34439](https://github.com/dotnet/efcore/issues/34439)

#### Old behavior

Previously, EF Core would (by default) wrap each migration in its own transaction when applying migrations.

#### New behavior

Starting with EF Core 9.0, all pending migrations are applied within a single transaction as part of [migration locking](xref:core/managing-schemas/migrations/applying#migration-locking). If any migration fails, the entire transaction is rolled back. This behavior was reverted in EF Core 10.

#### Why

Applying all migrations in a single transaction ensures the database is either fully up-to-date or left unchanged if an error occurs, avoiding intermediate states.

#### Mitigations

If you need per-migration transaction behavior in EF Core 9, upgrade to EF Core 10, which reverts to wrapping each migration in its own transaction.

## Azure Cosmos DB breaking changes

Extensive work has gone into making the Azure Cosmos DB provider better in 9.0. The changes include a number of high-impact breaking changes; if you are upgrading an existing application, please read the following carefully.
Expand Down
Loading