Exclude __EFMigrationsLock from SQLite scaffolding#38169
Merged
roji merged 2 commits intoApr 27, 2026
Merged
Conversation
- Add DefaultLockTableName public const to SqliteHistoryRepository - Exclude __EFMigrationsLock in SqliteDatabaseModelFactory.GetTables - Add test to verify EF-internal tables are not scaffolded Fixes dotnet#38148
There was a problem hiding this comment.
Pull request overview
This PR fixes SQLite reverse-engineering (scaffolding) to exclude EF-internal migrations infrastructure tables, specifically __EFMigrationsLock, matching the existing behavior for __EFMigrationsHistory (Fixes #38148).
Changes:
- Exclude
__EFMigrationsLockfromSqliteDatabaseModelFactory.GetTablesresults. - Introduce a shared constant for the default lock table name in
SqliteHistoryRepository. - Add a functional test verifying EF-internal tables aren’t scaffolded.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| test/EFCore.Sqlite.FunctionalTests/Scaffolding/SqliteDatabaseModelFactoryTest.cs | Adds a regression test ensuring __EFMigrationsLock isn’t scaffolded. |
| src/EFCore.Sqlite.Core/Scaffolding/Internal/SqliteDatabaseModelFactory.cs | Updates the sqlite_master query exclusion list to filter out the lock table. |
| src/EFCore.Sqlite.Core/Migrations/Internal/SqliteHistoryRepository.cs | Adds DefaultLockTableName constant and reuses it for LockTableName. |
Contributor
Author
|
@dotnet-policy-service agree |
- Move EF_internal_tables_are_not_scaffolded test to #region Table
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
Fixes #38148
When scaffolding a SQLite database that has had EF migrations applied, the
__EFMigrationsLocktable was incorrectly included in the scaffolded model. This table is EF-internal and should be excluded just like__EFMigrationsHistory.Root Cause
SqliteDatabaseModelFactory.GetTablesexplicitly excluded__EFMigrationsHistoryviaHistoryRepository.DefaultTableName, but did not exclude__EFMigrationsLock, which is created bySqliteHistoryRepositoryto implement distributed locking during migrations on SQLite.Changes
DefaultLockTableNamepublic const toSqliteHistoryRepositoryto avoid hardcoding the table name in multiple places.__EFMigrationsLockto the exclusion list inSqliteDatabaseModelFactory.GetTables.SqliteDatabaseModelFactoryTestto verify that EF-internal tables are not scaffolded.