Create and apply an EF Core migration for a module's DbContext the FSH way (central Migrations project, per-module folder, correct --context). Use after changing entities/EF config. See .agents/rules/database.md.
68
84%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
All migrations live in one project — src/Host/FSH.Starter.Migrations.PostgreSQL — but are foldered
per module/context (Catalog/, Identity/, …), each with its own {X}DbContextModelSnapshot. The DB
is not migrated at API startup; the DbMigrator host applies it.
dotnet tool restore # dotnet-ef is pinned in .config/dotnet-tools.jsondotnet ef migrations add reads the current snapshot, which is regenerated from a build. If you skip
the build after editing entities/config, you can generate against a stale snapshot and lose changes. Also,
migrations remove rewrites the snapshot — only remove the latest, and rebuild after.
dotnet build src/FSH.Starter.slnxSpecify all three of --project (the Migrations project), --startup-project (the API host), and
--context {X}DbContext. Use --output-dir {X} so it lands in that module's folder (match the existing
folder for the context).
dotnet ef migrations add {MigrationName} \
--project src/Host/FSH.Starter.Migrations.PostgreSQL \
--startup-project src/Host/FSH.Starter.Api \
--context {X}DbContext \
--output-dir {X}dotnet ef migrations script --idempotent \
--project src/Host/FSH.Starter.Migrations.PostgreSQL \
--startup-project src/Host/FSH.Starter.Api \
--context {X}DbContextCheck for: unintended table/column drops, non-nullable columns added without a default to an existing table, and renames surfacing as drop+add (data loss). Adjust the model or hand-edit the migration if needed.
Preferred (the canonical path — migrates the tenant catalog then each tenant's per-module schema):
dotnet run --project src/Host/FSH.Starter.DbMigrator -- apply
dotnet run --project src/Host/FSH.Starter.DbMigrator -- list-pending # to preview first(Or, single-context local dev, dotnet ef database update --context {X}DbContext --project … --startup-project ….)
{X}/ folder in the Migrations project and the runtime project referenced from it — see add-module.dotnet ef against a BaseDbContext works because the 4-arg ctor is satisfied by the startup host's DI.dotnet tool restore done (first time)migrations add--context {X}DbContext + --output-dir {X} (lands in the right folder)apply (or ef database update for one context locally)3f2959e
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.