dotnet-ef-migration
Skill1 starsChanged yesterdayMITView on GitHub
Create, review, list, remove or script an EF Core migration for one module of a .NET modular monolith (one DbContext per module). Use after changing an entity or its configuration, or when asked to add a migration.
In this repository84 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/angular-coding-style.mdcCursor rule
- .cursor/rules/angular-patterns.mdcCursor rule
- .cursor/rules/angular-security.mdcCursor rule
- .cursor/rules/angular-testing.mdcCursor rule
- .cursor/rules/common-code-review.mdcCursor rule
- .cursor/rules/common-coding-style.mdcCursor rule
- .cursor/rules/common-development-workflow.mdcCursor rule
- .cursor/rules/common-security.mdcCursor rule
- .cursor/rules/common-testing.mdcCursor rule
- .cursor/rules/csharp-coding-style.mdcCursor rule
- .cursor/rules/csharp-data-access.mdcCursor rule
- .cursor/rules/csharp-patterns.mdcCursor rule
- .cursor/rules/csharp-security.mdcCursor rule
- .cursor/rules/csharp-testing.mdcCursor rule
- .cursor/rules/design-design-system.mdcCursor rule
- .cursor/rules/project-backend.mdcCursor rule
- .cursor/rules/project-security.mdcCursor rule
- .cursor/rules/project-testing.mdcCursor rule
- .cursor/rules/project-web.mdcCursor rule
- .cursor/rules/typescript-coding-style.mdcCursor rule
- .cursor/rules/typescript-patterns.mdcCursor rule
- .cursor/rules/typescript-security.mdcCursor rule
- .cursor/rules/typescript-testing.mdcCursor rule
- angular-guideSkill
- break-uiSkill
- dotnet-create-command-querySkill
- dotnet-create-entitySkill
- dotnet-create-moduleSkill
- dotnet-ef-migrationSkill
- emil-design-engSkill
- frontend-designSkill
- impeccableSkill
- review-animationsSkill
- speckit-analyzeSkill
- speckit-checklistSkill
- speckit-clarifySkill
- speckit-constitutionSkill
- speckit-convergeSkill
- speckit-implementSkill
- speckit-planSkill
- speckit-specifySkill
- speckit-tasksSkill
- ui-ux-pro-maxSkill
- angular-guideSkill
- break-uiSkill
- dotnet-create-command-querySkill
- dotnet-create-entitySkill
- dotnet-create-moduleSkill
- emil-design-engSkill
- frontend-designSkill
- impeccableSkill
- review-animationsSkill
- speckit-analyzeSkill
- speckit-checklistSkill
- speckit-clarifySkill
- speckit-constitutionSkill
- speckit-convergeSkill
- speckit-implementSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
Never write or edit migration files by hand.
- Very specific: line 25
If the context name is ambiguous across modules, pass the fully qualified name (<Module>.Infrastructure.Database.<Module>DbContext).
- Distinctive: line 28
only this module's schema is touched.
- Very specific: line 29
no unintended drops or renames (EF turns a rename into drop + add unless told: use RenameColumn/RenameTable).
- Distinctive: line 34
Commit the model change and the migration together.
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
EF Core migration for a module
Inputs: the migration name (PascalCase, says what changed) and the module. Find the paths from the repo first:
<Module>.Infrastructure project, the startup (host) project, and the <Module>DbContext class. Read the repo's
AGENTS.md/CLAUDE.md: if it names another output folder or command, use that.
Never write or edit migration files by hand; the tool generates them.
Steps
- Model change complete (entity,
IEntityTypeConfiguration<T>,DbSetif new).dotnet buildpasses. - Generate:
If the context name is ambiguous across modules, pass the fully qualified name (dotnet ef migrations add <Name> \ --project src/Modules/<Module>/<Module>.Infrastructure/<Module>.Infrastructure.csproj \ --startup-project src/<Host>/<Host>.csproj \ --context <Module>DbContext \ --output-dir Database/Migrations<Module>.Infrastructure.Database.<Module>DbContext). - Review the generated
Up()andDown():- only this module's schema is touched;
- no unintended drops or renames (EF turns a rename into drop + add unless told: use
RenameColumn/RenameTable); - indexes and unique constraints include the tenant column when the table is tenant-scoped;
- data backfills (
migrationBuilder.Sql(...)) are idempotent and parameter-free.
- Apply locally:
dotnet ef database update --project ... --startup-project ... --context <Module>DbContext(or the repo's own startup migration step). Run the tests. - Commit the model change and the migration together.
Other commands (same --project/--startup-project/--context)
| Need | Command |
| Undo the last, unapplied migration | dotnet ef migrations remove ... |
| List | dotnet ef migrations list ... |
| Deployment script | dotnet ef migrations script --idempotent --output <Name>.sql ... |
Naming
Add<X>Table, Add<Column>To<Table>, Add<X>Index, Add<X>Relation, Remove<X>, Rename<X>To<Y>,
Backfill<X>.
Troubleshooting
- "No DbContext was found": the context is not registered by the module's
DependencyInjection, or the startup project does not reference the module. - "More than one DbContext": pass
--context. - Pending model changes after generating: something else changed the model; build and diff again.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

