Skip to content

Add note about PendingModelChangesWarning behavior in EF Core 9#5390

Open
sayinbrahim wants to merge 2 commits into
dotnet:mainfrom
sayinbrahim:patch-1
Open

Add note about PendingModelChangesWarning behavior in EF Core 9#5390
sayinbrahim wants to merge 2 commits into
dotnet:mainfrom
sayinbrahim:patch-1

Conversation

@sayinbrahim

Copy link
Copy Markdown

Summary

EF Core 9 introduced a behavioral change where Migrate() and MigrateAsync() throw a PendingModelChangesWarning exception 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

  • Added a note in the "Migration locking" section of applying.md, immediately after the existing SQL scripts are not affected by migration locking paragraph
  • Cross-linked to the existing has-pending-model-changes command in managing.md as the recommended detection pattern
  • Note placement follows existing [!NOTE] / [!WARNING] conventions used elsewhere in the file

Why this matters

Developers encountering the PendingModelChangesWarning exception during Migrate() 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

  • Cross-link target managing.md#checking-for-pending-model-changes exists in the destination file
  • Note format matches existing [!NOTE] blocks in the documentation
  • Preview confirmed correct rendering

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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” in applying.md describing the EF Core 9 pending-model-changes behavior for Migrate()/MigrateAsync().
  • Cross-links to dotnet ef migrations has-pending-model-changes in managing.md as 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add See [breaking change note](xref:core/what-is-new/ef-core-9.0/breaking-changes#pending-model-changes) for more information.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use xref syntax for linking

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to xref syntax.

… 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants