Skip to content

Document migration locking#5330

Merged
AndriySvyryd merged 5 commits intomainfrom
copilot/update-migration-lock-docs
Apr 16, 2026
Merged

Document migration locking#5330
AndriySvyryd merged 5 commits intomainfrom
copilot/update-migration-lock-docs

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 14, 2026

EF Core 9 introduced a migration locking mechanism (dotnet/efcore#34115, dotnet/efcore#34338) that was never properly documented. The aka.ms/efcore-docs-migrations-lock link had no target content.

New section in applying.md: Migration locking

  • When it applies: dotnet ef database update, Update-Database, bundles, MigrateAsync()/Migrate() — not SQL scripts
  • Provider-specific warning: A [!WARNING] block alerts readers that locking varies across providers and can involve provider-specific issues (e.g. SQLite abandoned locks)
  • Limitations: Concise bullet list noting that wrapping MigrateAsync in an explicit transaction is not supported (links to the EF9 breaking change note) and that SQLite abandoned locks can block subsequent migrations (links to SQLite limitations)

SQLite limitations (sqlite/limitations.md): Expanded "Concurrent migrations protection"

  • How the lock works: SQLite uses __EFMigrationsLock table (vs. SQL Server's session-level sp_getapplock)
  • Handling abandoned locks: Lock rows can survive process termination — documented both fixes:
DROP TABLE "__EFMigrationsLock";
-- or
DELETE FROM "__EFMigrationsLock";

Cross-reference updates

  • data-seeding.md: migration locking link now points to new section instead of whatsnew
  • whatsnew.md (EF9): added forward link to new docs

Copilot AI linked an issue Apr 14, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Update documentation for migration locking handling Document migration locking Apr 14, 2026
Copilot AI requested a review from AndriySvyryd April 14, 2026 17:45
@AndriySvyryd AndriySvyryd requested a review from Copilot April 14, 2026 18:20
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds missing EF Core 9 documentation for the migrations concurrency/locking mechanism (the previously un-targeted aka.ms/efcore-docs-migrations-lock concept), and updates related pages to cross-reference the new authoritative section.

Changes:

  • Add a new Migration locking section to the “Applying migrations” documentation, including provider-specific behavior (SQL Server vs SQLite), abandoned-lock remediation, and explicit-transaction interaction.
  • Update cross-references in EF9 “What’s New”, SQLite limitations, and data seeding docs to point to the new section.
  • Add SQLite guidance (including a SQL snippet) for clearing abandoned migration locks.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
entity-framework/core/what-is-new/ef-core-9.0/whatsnew.md Adds a forward link from the EF9 release notes to the new migration locking documentation section.
entity-framework/core/providers/sqlite/limitations.md Updates the SQLite “Concurrent migrations protection” section to reference the new docs and includes a remediation SQL snippet.
entity-framework/core/modeling/data-seeding.md Updates the seeding docs to reference migration locking via the new canonical link.
entity-framework/core/managing-schemas/migrations/applying.md Introduces the new “Migration locking” documentation section with details, examples, and mitigation guidance.

Comment thread entity-framework/core/managing-schemas/migrations/applying.md Outdated
Comment thread entity-framework/core/managing-schemas/migrations/applying.md Outdated
Comment thread entity-framework/core/providers/sqlite/limitations.md
Comment thread entity-framework/core/providers/sqlite/limitations.md Outdated
…, make code sample self-contained

Agent-Logs-Url: https://github.com/dotnet/EntityFramework.Docs/sessions/746024ca-0b2a-4a41-aae0-d72cadbd0353

Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Copilot AI requested a review from AndriySvyryd April 14, 2026 18:48
@AndriySvyryd AndriySvyryd marked this pull request as ready for review April 14, 2026 18:51
Copilot AI review requested due to automatic review settings April 14, 2026 18:51
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread entity-framework/core/managing-schemas/migrations/applying.md Outdated
@AndriySvyryd AndriySvyryd enabled auto-merge (squash) April 16, 2026 00:10
@roji roji disabled auto-merge April 16, 2026 06:57
Copy link
Copy Markdown
Member

@roji roji left a comment

Choose a reason for hiding this comment

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

LGTM but see comments/suggestions.

Comment thread entity-framework/core/managing-schemas/migrations/applying.md Outdated
Comment thread entity-framework/core/managing-schemas/migrations/applying.md Outdated
Comment thread entity-framework/core/managing-schemas/migrations/applying.md Outdated
@roji roji removed their assignment Apr 16, 2026
…lify transaction section

Agent-Logs-Url: https://github.com/dotnet/EntityFramework.Docs/sessions/37325281-a3df-43c1-95d6-2fb1a37c55c9

Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Comment thread entity-framework/core/managing-schemas/migrations/applying.md
Comment thread entity-framework/core/managing-schemas/migrations/applying.md Outdated
Copilot AI requested review from Copilot and removed request for Copilot April 16, 2026 17:37
Copilot AI requested a review from AndriySvyryd April 16, 2026 17:38
@AndriySvyryd AndriySvyryd merged commit 90db92a into main Apr 16, 2026
5 checks passed
@AndriySvyryd AndriySvyryd deleted the copilot/update-migration-lock-docs branch April 16, 2026 18:15
roji pushed a commit to roji/EntityFramework.Docs that referenced this pull request Apr 30, 2026
Fixes dotnet#4783
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
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.

Document migration locking

4 participants