From 5c3dfff99fedc7b2ce538bcb71ea0240b4d47983 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 4 Mar 2026 22:29:09 +0000
Subject: [PATCH 1/8] Initial plan
From 7226369d49112dd1e362963049feecd0c01f68f4 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 4 Mar 2026 22:31:58 +0000
Subject: [PATCH 2/8] Document breaking changes for EFOptimizeContext removal
(#35079) and MigrationsNotFound throw (#35218)
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
---
.../ef-core-11.0/breaking-changes.md | 69 +++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git a/entity-framework/core/what-is-new/ef-core-11.0/breaking-changes.md b/entity-framework/core/what-is-new/ef-core-11.0/breaking-changes.md
index 13488484c5..d4a83add2f 100644
--- a/entity-framework/core/what-is-new/ef-core-11.0/breaking-changes.md
+++ b/entity-framework/core/what-is-new/ef-core-11.0/breaking-changes.md
@@ -19,6 +19,8 @@ This page documents API and behavior changes that have the potential to break ex
| **Breaking change** | **Impact** |
|:--------------------------------------------------------------------------------------------------------------- | -----------|
| [Sync I/O via the Azure Cosmos DB provider has been fully removed](#cosmos-nosync) | Medium |
+| [EF Core now throws by default when no migrations are found](#migrations-not-found) | Medium |
+| [`EFOptimizeContext` MSBuild property has been removed](#ef-optimize-context-removed) | Low |
| [EF tools packages no longer reference Microsoft.EntityFrameworkCore.Design](#ef-tools-no-design-dep) | Low |
## Medium-impact changes
@@ -45,8 +47,75 @@ Synchronous blocking on asynchronous methods ("sync-over-async") is highly disco
Convert your code to use async I/O APIs instead of sync I/O ones. For example, replace calls to `SaveChanges()` with `await SaveChangesAsync()`.
+
+
+### EF Core now throws by default when no migrations are found
+
+[Tracking Issue #35218](https://github.com/dotnet/efcore/issues/35218)
+
+#### Old behavior
+
+Previously, when calling or on a database with no migrations in the assembly, EF Core logged an informational message and returned without applying any changes.
+
+#### New behavior
+
+Starting with EF Core 11.0, EF Core throws an exception by default when no migrations are found in the assembly. This is consistent with the `PendingModelChangesWarning` behavior [introduced in EF 9.0](xref:core/what-is-new/ef-core-9.0/breaking-changes#pending-model-changes), which was updated in 9.0.1 to exclude the case when there are no migrations at all. This change now covers that case by throwing for the event.
+
+#### Why
+
+Calling `Migrate()` or `MigrateAsync()` when no migrations exist typically indicates a misconfiguration. Rather than silently continuing and leaving the database in a potentially incorrect state, EF Core now alerts developers to this issue immediately.
+
+#### Mitigations
+
+If you intentionally call `Migrate()` without having any migrations (for example, because you manage the database schema through other means), suppress the exception by configuring warnings:
+
+```csharp
+options.ConfigureWarnings(w => w.Ignore(RelationalEventId.MigrationsNotFound))
+```
+
+Or to log the event instead of throwing:
+
+```csharp
+options.ConfigureWarnings(w => w.Log(RelationalEventId.MigrationsNotFound))
+```
+
## Low-impact changes
+
+
+### `EFOptimizeContext` MSBuild property has been removed
+
+[Tracking Issue #35079](https://github.com/dotnet/efcore/issues/35079)
+
+#### Old behavior
+
+Previously, the `EFOptimizeContext` MSBuild property could be set to `true` to enable compiled model and precompiled query code generation during build or publish:
+
+```xml
+true
+```
+
+#### New behavior
+
+Starting with EF Core 11.0, the `EFOptimizeContext` MSBuild property has been removed. Code generation is now controlled exclusively through the `EFScaffoldModelStage` and `EFPrecompileQueriesStage` properties. When `PublishAOT` is set to `true`, code generation is automatically enabled during publish without needing any additional property.
+
+#### Why
+
+The `EFScaffoldModelStage` and `EFPrecompileQueriesStage` properties already provide fine-grained control over when code generation occurs. `EFOptimizeContext` was a redundant enablement gate.
+
+#### Mitigations
+
+Replace usages of `EFOptimizeContext` with the `EFScaffoldModelStage` and `EFPrecompileQueriesStage` properties. These can be set to `publish` or `build` to control at which stage code generation occurs:
+
+```xml
+publish
+publish
+```
+
+Any other value (for example, `none`) disables the corresponding generation.
+
+If you have `PublishAOT` set to `true`, code generation is automatically enabled during publish and no additional configuration is needed.
+
### EF tools packages no longer reference Microsoft.EntityFrameworkCore.Design
From b221a3d7dc8d4d2bfd095ec6a4ac7f5311d3af20 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 4 Mar 2026 22:43:21 +0000
Subject: [PATCH 3/8] Address review: change MigrationsNotFound to low impact
and simplify new behavior text
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
---
.../core/what-is-new/ef-core-11.0/breaking-changes.md | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/entity-framework/core/what-is-new/ef-core-11.0/breaking-changes.md b/entity-framework/core/what-is-new/ef-core-11.0/breaking-changes.md
index d4a83add2f..268bacca92 100644
--- a/entity-framework/core/what-is-new/ef-core-11.0/breaking-changes.md
+++ b/entity-framework/core/what-is-new/ef-core-11.0/breaking-changes.md
@@ -19,7 +19,7 @@ This page documents API and behavior changes that have the potential to break ex
| **Breaking change** | **Impact** |
|:--------------------------------------------------------------------------------------------------------------- | -----------|
| [Sync I/O via the Azure Cosmos DB provider has been fully removed](#cosmos-nosync) | Medium |
-| [EF Core now throws by default when no migrations are found](#migrations-not-found) | Medium |
+| [EF Core now throws by default when no migrations are found](#migrations-not-found) | Low |
| [`EFOptimizeContext` MSBuild property has been removed](#ef-optimize-context-removed) | Low |
| [EF tools packages no longer reference Microsoft.EntityFrameworkCore.Design](#ef-tools-no-design-dep) | Low |
@@ -47,6 +47,8 @@ Synchronous blocking on asynchronous methods ("sync-over-async") is highly disco
Convert your code to use async I/O APIs instead of sync I/O ones. For example, replace calls to `SaveChanges()` with `await SaveChangesAsync()`.
+## Low-impact changes
+
### EF Core now throws by default when no migrations are found
@@ -59,7 +61,7 @@ Previously, when calling event.
+Starting with EF Core 11.0, EF Core throws an exception by default when no migrations are found in the assembly. This is consistent with the `PendingModelChangesWarning` behavior [introduced in EF 9.0](xref:core/what-is-new/ef-core-9.0/breaking-changes#pending-model-changes).
#### Why
@@ -79,8 +81,6 @@ Or to log the event instead of throwing:
options.ConfigureWarnings(w => w.Log(RelationalEventId.MigrationsNotFound))
```
-## Low-impact changes
-
### `EFOptimizeContext` MSBuild property has been removed
From 2009bbd9152f58ab562cbfcf7003af93c4fa53c9 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 4 Mar 2026 23:04:51 +0000
Subject: [PATCH 4/8] Update MSBuild integration page to note EFOptimizeContext
removal in EF Core 11
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
---
entity-framework/core/cli/msbuild.md | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/entity-framework/core/cli/msbuild.md b/entity-framework/core/cli/msbuild.md
index 7a537fa00b..192390815b 100644
--- a/entity-framework/core/cli/msbuild.md
+++ b/entity-framework/core/cli/msbuild.md
@@ -30,14 +30,17 @@ If the project specifies `true` then by default the MSB
| MSBuild property | Description |
|--------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| EFOptimizeContext | Set to `true` to enable MSBuild integration. |
-| EFScaffoldModelStage | Set to `publish`, `build` or `none` to indicate at which stage the compiled model will be generated. Defaults to `publish`. |
-| EFPrecompileQueriesStage | Set to `publish`, `build` or `none` to indicate at which stage the precompiled queries will be generated. Defaults to `publish`. |
+| EFOptimizeContext | Set to `true` to enable MSBuild integration. **EF Core 9-10 only; removed in EF Core 11.** |
+| EFScaffoldModelStage | Set to `publish`, `build` or `none` to indicate at which stage the compiled model will be generated. Defaults to `publish`. **EF Core 9-10**: requires `EFOptimizeContext` to be `true`. **EF Core 11+**: automatically enabled without `EFOptimizeContext`. |
+| EFPrecompileQueriesStage | Set to `publish`, `build` or `none` to indicate at which stage the precompiled queries will be generated. Defaults to `publish`. **EF Core 9-10**: requires `EFOptimizeContext` to be `true`. **EF Core 11+**: automatically enabled without `EFOptimizeContext`. |
| DbContextName | The derived `DbContext` class to use. Class name only or fully qualified with namespaces. If this option is omitted, EF Core will perform generation for all context classes in the project. |
| EFTargetNamespace | The namespace to use for all generated classes. If this option is omitted, EF Core will use `$(RootNamespace)`. |
| EFOutputDir | The folder to put the generated files before the project is compiled. If this option is omitted, EF Core will use `$(IntermediateOutputPath)`. |
| EFNullable | Whether nullable reference types will be used in the generated code. If this option is omitted, EF Core will use `$(Nullable)`. |
+> [!NOTE]
+> Starting with EF Core 11, the `EFOptimizeContext` property has been [removed](xref:core/what-is-new/ef-core-11.0/breaking-changes#ef-optimize-context-removed). The `EFScaffoldModelStage` and `EFPrecompileQueriesStage` properties now work independently and don't require an additional enablement flag.
+
## Limitations
* When using the integration during the `publish` stage also set the rid in the startup project (e.g. \win-x64\)
From 66d4a1ef8b4c197fe60bce72c5f995920ba2b9ac Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 4 Mar 2026 23:08:03 +0000
Subject: [PATCH 5/8] Revert MSBuild integration page changes per review
feedback
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
---
entity-framework/core/cli/msbuild.md | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/entity-framework/core/cli/msbuild.md b/entity-framework/core/cli/msbuild.md
index 192390815b..7a537fa00b 100644
--- a/entity-framework/core/cli/msbuild.md
+++ b/entity-framework/core/cli/msbuild.md
@@ -30,17 +30,14 @@ If the project specifies `true` then by default the MSB
| MSBuild property | Description |
|--------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| EFOptimizeContext | Set to `true` to enable MSBuild integration. **EF Core 9-10 only; removed in EF Core 11.** |
-| EFScaffoldModelStage | Set to `publish`, `build` or `none` to indicate at which stage the compiled model will be generated. Defaults to `publish`. **EF Core 9-10**: requires `EFOptimizeContext` to be `true`. **EF Core 11+**: automatically enabled without `EFOptimizeContext`. |
-| EFPrecompileQueriesStage | Set to `publish`, `build` or `none` to indicate at which stage the precompiled queries will be generated. Defaults to `publish`. **EF Core 9-10**: requires `EFOptimizeContext` to be `true`. **EF Core 11+**: automatically enabled without `EFOptimizeContext`. |
+| EFOptimizeContext | Set to `true` to enable MSBuild integration. |
+| EFScaffoldModelStage | Set to `publish`, `build` or `none` to indicate at which stage the compiled model will be generated. Defaults to `publish`. |
+| EFPrecompileQueriesStage | Set to `publish`, `build` or `none` to indicate at which stage the precompiled queries will be generated. Defaults to `publish`. |
| DbContextName | The derived `DbContext` class to use. Class name only or fully qualified with namespaces. If this option is omitted, EF Core will perform generation for all context classes in the project. |
| EFTargetNamespace | The namespace to use for all generated classes. If this option is omitted, EF Core will use `$(RootNamespace)`. |
| EFOutputDir | The folder to put the generated files before the project is compiled. If this option is omitted, EF Core will use `$(IntermediateOutputPath)`. |
| EFNullable | Whether nullable reference types will be used in the generated code. If this option is omitted, EF Core will use `$(Nullable)`. |
-> [!NOTE]
-> Starting with EF Core 11, the `EFOptimizeContext` property has been [removed](xref:core/what-is-new/ef-core-11.0/breaking-changes#ef-optimize-context-removed). The `EFScaffoldModelStage` and `EFPrecompileQueriesStage` properties now work independently and don't require an additional enablement flag.
-
## Limitations
* When using the integration during the `publish` stage also set the rid in the startup project (e.g. \win-x64\)
From 4a9756bdbc514b1138fddd517a0d3ea35a993423 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 5 Mar 2026 00:59:11 +0000
Subject: [PATCH 6/8] Add note about EFOptimizeContext removal in EF Core 11 to
MSBuild integration page
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
---
entity-framework/core/cli/msbuild.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/entity-framework/core/cli/msbuild.md b/entity-framework/core/cli/msbuild.md
index 7a537fa00b..594786a0bb 100644
--- a/entity-framework/core/cli/msbuild.md
+++ b/entity-framework/core/cli/msbuild.md
@@ -30,7 +30,7 @@ If the project specifies `true` then by default the MSB
| MSBuild property | Description |
|--------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| EFOptimizeContext | Set to `true` to enable MSBuild integration. |
+| EFOptimizeContext | Set to `true` to enable MSBuild integration. **EF Core 9-10 only; removed in EF Core 11.** |
| EFScaffoldModelStage | Set to `publish`, `build` or `none` to indicate at which stage the compiled model will be generated. Defaults to `publish`. |
| EFPrecompileQueriesStage | Set to `publish`, `build` or `none` to indicate at which stage the precompiled queries will be generated. Defaults to `publish`. |
| DbContextName | The derived `DbContext` class to use. Class name only or fully qualified with namespaces. If this option is omitted, EF Core will perform generation for all context classes in the project. |
From 6839ccadc1efb25bdb88bdf00a6f33eb095d4416 Mon Sep 17 00:00:00 2001
From: Andriy Svyryd
Date: Wed, 4 Mar 2026 17:29:50 -0800
Subject: [PATCH 7/8] Add a note to msbuild.md
---
entity-framework/core/cli/msbuild.md | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/entity-framework/core/cli/msbuild.md b/entity-framework/core/cli/msbuild.md
index 594786a0bb..7302fa5904 100644
--- a/entity-framework/core/cli/msbuild.md
+++ b/entity-framework/core/cli/msbuild.md
@@ -2,7 +2,7 @@
title: EF Core MSBuild tasks - EF Core
description: Reference guide for the Entity Framework Core .NET MSBuild tasks
author: AndriySvyryd
-ms.date: 01/17/2025
+ms.date: 03/04/2026
uid: core/cli/msbuild
---
@@ -38,6 +38,9 @@ If the project specifies `true` then by default the MSB
| EFOutputDir | The folder to put the generated files before the project is compiled. If this option is omitted, EF Core will use `$(IntermediateOutputPath)`. |
| EFNullable | Whether nullable reference types will be used in the generated code. If this option is omitted, EF Core will use `$(Nullable)`. |
+> [!NOTE]
+> Starting with EF Core 11, the `EFOptimizeContext` property has been [removed](xref:core/what-is-new/ef-core-11.0/breaking-changes#ef-optimize-context-removed). The `EFScaffoldModelStage` and `EFPrecompileQueriesStage` properties now work independently and don't require an additional enablement flag.
+
## Limitations
* When using the integration during the `publish` stage also set the rid in the startup project (e.g. \win-x64\)
From 9cec2a5d3e92f50bee462b7f5f90336ebe4aa6a3 Mon Sep 17 00:00:00 2001
From: Andriy Svyryd
Date: Thu, 5 Mar 2026 14:43:20 -0800
Subject: [PATCH 8/8] Clarify mitigation for Migrate() without migrations
Updated the mitigation section to clarify how to handle calling Migrate without migrations.
---
.../core/what-is-new/ef-core-11.0/breaking-changes.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/entity-framework/core/what-is-new/ef-core-11.0/breaking-changes.md b/entity-framework/core/what-is-new/ef-core-11.0/breaking-changes.md
index 268bacca92..047b586890 100644
--- a/entity-framework/core/what-is-new/ef-core-11.0/breaking-changes.md
+++ b/entity-framework/core/what-is-new/ef-core-11.0/breaking-changes.md
@@ -69,7 +69,7 @@ Calling `Migrate()` or `MigrateAsync()` when no migrations exist typically indic
#### Mitigations
-If you intentionally call `Migrate()` without having any migrations (for example, because you manage the database schema through other means), suppress the exception by configuring warnings:
+If you intentionally call `Migrate()` without having any migrations (for example, because you manage the database schema through other means), remove the `Migrate()` call or suppress the exception by configuring warnings:
```csharp
options.ConfigureWarnings(w => w.Ignore(RelationalEventId.MigrationsNotFound))