fix: handle wildcard '*' in --context parameter for UpdateDatabase an…#38269
fix: handle wildcard '*' in --context parameter for UpdateDatabase an…#38269BrunoSync wants to merge 3 commits into
Conversation
…d MigrationsBundle
There was a problem hiding this comment.
Pull request overview
This PR adds wildcard --context * handling to migration database updates so EF Core tooling can attempt to update all discovered DbContext types.
Changes:
- Adds a wildcard branch in
MigrationsOperations.UpdateDatabase. - Adds a test intended to cover wildcard update behavior across multiple contexts.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/EFCore.Design/Design/Internal/MigrationsOperations.cs |
Adds CreateAllContexts() iteration for contextType == "*". |
test/EFCore.Design.Tests/Design/Internal/MigrationsOperationsTest.cs |
Adds wildcard update test coverage. |
- Implement wildcard support in UpdateDatabase method - Throw OperationException when no contexts found (consistency with non-wildcard path) - MigrationsBundle covered by this fix (calls UpdateDatabase internally) - Remove weak test coverage (no existing tests for UpdateDatabase in codebase)
Implementation Notes for ReviewHi @dotnet/efcore-team, I've addressed the wildcard Changes Made
Design Decision: Why AddMigration is Excluded
Testing ApproachI noticed
Please let me know if you'd like me to approach testing differently or if there's additional context needed. Thanks for reviewing! |
That would be a big change, so it should be done separately - #38278 |
Fix wildcard '*' support in --context parameter
Fixes #38254
What was done
UpdateDatabase— when--context *is passed, the operation now callsCreateAllContexts()and iterates over all found contextsMigrationsBundleis covered by this fix since it internally callsUpdateDatabaseUpdateDatabase_with_wildcard_context_runs_for_all_contextsto verify the fixPending
AddMigrationalso needs wildcard support, but since it returnsMigrationFiles, iterating over multiple contexts raises a design question about the return value. Looking for guidance on how to handle this before implementing.