Add note about PendingModelChangesWarning behavior in EF Core 9#5390
Open
sayinbrahim wants to merge 2 commits into
Open
Add note about PendingModelChangesWarning behavior in EF Core 9#5390sayinbrahim wants to merge 2 commits into
sayinbrahim wants to merge 2 commits into
Conversation
EF Core 9 introduced a breaking change where Migrate() and MigrateAsync() throw a PendingModelChangesWarning exception when the model has pending changes compared to the last migration. This note cross-references the existing has-pending-model-changes command in managing.md as the recommended CI/CD detection pattern.
Contributor
There was a problem hiding this comment.
Pull request overview
Surfaces an EF Core 9 runtime migration behavior change (throwing when there are pending model changes) in the primary “applying migrations” documentation, and points readers to the recommended pre-deployment detection approach.
Changes:
- Adds a
[!NOTE]under “Migration locking” inapplying.mddescribing the EF Core 9 pending-model-changes behavior forMigrate()/MigrateAsync(). - Cross-links to
dotnet ef migrations has-pending-model-changesinmanaging.mdas a CI/CD check.
Comment on lines
+359
to
+366
| > Starting with EF Core 9, calling `Migrate()` or `MigrateAsync()` will | ||
| > throw a `PendingModelChangesWarning` exception when the model has | ||
| > pending changes compared to the last migration. To detect this | ||
| > condition before deployment, use the | ||
| > [`dotnet ef migrations has-pending-model-changes`](managing.md#checking-for-pending-model-changes) | ||
| > command in your CI/CD pipeline. The warning can be suppressed via | ||
| > `ConfigureWarnings` if necessary, but this is generally not | ||
| > recommended in production scenarios. |
| > [`dotnet ef migrations has-pending-model-changes`](managing.md#checking-for-pending-model-changes) | ||
| > command in your CI/CD pipeline. The warning can be suppressed via | ||
| > `ConfigureWarnings` if necessary, but this is generally not | ||
| > recommended in production scenarios. |
Member
There was a problem hiding this comment.
Add See [breaking change note](xref:core/what-is-new/ef-core-9.0/breaking-changes#pending-model-changes) for more information.
Author
There was a problem hiding this comment.
Added at the end of the note. Thanks!
| > throw a `PendingModelChangesWarning` exception when the model has | ||
| > pending changes compared to the last migration. To detect this | ||
| > condition before deployment, use the | ||
| > [`dotnet ef migrations has-pending-model-changes`](managing.md#checking-for-pending-model-changes) |
Member
There was a problem hiding this comment.
Use xref syntax for linking
… add breaking change link - Reworded note to distinguish the exception from the warning event ID per Copilot review - Changed both links to xref syntax per AndriySvyryd review - Added See [breaking change note] link at the end per AndriySvyryd review - Removed trailing whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
EF Core 9 introduced a behavioral change where
Migrate()andMigrateAsync()throw aPendingModelChangesWarningexception when the model has pending changes compared to the last migration. This is documented in the EF Core 9 breaking changes page but is not surfaced in the primary documentation about applying migrations.Changes
applying.md, immediately after the existingSQL scripts are not affected by migration lockingparagraphhas-pending-model-changescommand inmanaging.mdas the recommended detection pattern[!NOTE]/[!WARNING]conventions used elsewhere in the fileWhy this matters
Developers encountering the
PendingModelChangesWarningexception duringMigrate()calls in production deployments typically search the runtime migration documentation first. Without a cross-reference, they may not discover the existing detection command that prevents this issue in CI/CD pipelines.Verification
managing.md#checking-for-pending-model-changesexists in the destination file[!NOTE]blocks in the documentation