ef-add-migration
Add an EF Core migration in the open workspace. Discovers startup project, DbContext, and migrations folder. Use when adding a migration or invoking /ef-add-migration.
- License 许可
- MIT
- 最近更新
- 2026-11-08
- Stars
- ★ 6
- Forks
- 0
01 前言 Front Matter
- name
- ef-add-migration
- description
- Add an EF Core migration in the open workspace. Discovers startup project, DbContext, and migrations folder. Use when adding a migration or invoking /ef-add-migration.
02 资源文件 7
- 参考文档reference.md607 B
- 参考文档references/artifacts.md235 B
- 参考文档references/commands.md413 B
- 参考文档references/discovery.md703 B
- 参考文档references/ef-tool.md683 B
- 参考文档references/naming.md499 B
- 参考文档references/sdd-cross-cut.md472 B
03 SKILL.md 正文
STOP - Read before ANY tool call
Read _shared/skill-boilerplate.md first. It holds the guardrails read, the session gate rule, the user sim rule, the one-step rule, the gate check, and the user chat language rule. The steps below are skill-specific only.
Skill: ef-add-migration
Trigger
Negative signal: applies as defined in _shared/skill-boilerplate.md; the skill-specific signals are listed below.
Invoke when the user asks for: /ef-add-migration, add migration, /ef-add-migration, or when a PLAN step requires a new EF Core migration.
Optional argument: migration name in PascalCase. If omitted, infer from pending model changes and confirm with the user.
Outcome
A new EF Core migration in the target workspace (not this toolkit repo unless that repo has a DbContext). User sees detected projects, final migration name, and created file paths.
Lazy-load
| When | Path |
|---|---|
| Reference index (routing only) | skills/ef-add-migration/reference.md or {{TOOLKIT_ROOT}}/skills/ef-add-migration/reference.md after sync |
| Process step detail (lazy) | skills/ef-add-migration/references/<section>.md |
| .NET layering | {{TOOLKIT_ROOT}}/skills/_shared/dotnet-guidelines/clean-architecture.md |
| .NET test patterns (when adding tests) | {{TOOLKIT_ROOT}}/skills/_shared/dotnet-guidelines/dotnet-test-patterns.md |
Never by default: do not preload all references/*.md, full EF docs, or unrelated dotnet guideline packs. Load one references/<section>.md per Process step (SKILL-REFERENCE-RETRIEVAL.md).
Process
Read references/<section>.md for discovery/commands — not full reference.md.
0. Workspace
Confirm the target .NET repository (.sln or *.csproj with DbContext). If the workspace is the toolkit only, stop and ask which repo to open.
1. Discover project layout
Use Glob and Grep (not hardcoded paths). Full checklist: references/discovery.md.
Summarize before running dotnet ef:
| Setting | Detected value |
|---|---|
| Solution root | path to .sln or repo root |
| Startup project | API/Host/Web/Worker with Program.cs |
| Target project | .csproj containing DbContext |
| DbContext class | e.g. ApplicationDbContext |
| Migrations folder | existing Migrations/ or default under target |
If any value is ambiguous, ask the user once. Free text: the answer is a path or name, not a fixed id set; the question stays open until answered.
2. Migration name
- Name provided: normalize to PascalCase.
- Name omitted: inspect
git diff/git status, infer from entity/schema changes (seereferences/naming.md), present the suggested name, then ask once. Single select; idsconfirm(use the name),adjust(free-text name instead),cancel(no migration). Render labels in the user chat language; answer mapping:{{TOOLKIT_ROOT}}/skills/_shared/agents/QUESTIONS.md.
3. Ensure dotnet-ef
dotnet ef --version
If missing, follow references/ef-tool.md (global or local tool-path; no fixed version in this skill body).
4. Add migration
From solution root:
dotnet ef migrations add <MigrationName> -s <StartupProject> -p <TargetProject> -c <DbContext>
Use ./dotnet-ef instead of dotnet ef when a repo-local tool is documented in references/ef-tool.md or repo README. Command details: references/commands.md.
5. Verify and summarize
Confirm new *.cs + *.Designer.cs and updated *ModelSnapshot.cs under the migrations folder (references/artifacts.md). Do not hand-edit generated migration code in ways that violate structure-and-quality.md / csharp-patterns.md. Optionally note how to apply locally (database update - details in references/commands.md). SDD handoff: references/sdd-cross-cut.md.
Must not
- Hardcode EF tool package versions in
SKILL.md(usereferences/ef-tool.md) - Assume corporate feeds or organization-specific URLs
- Run migrations against production without explicit user request
- Modify this toolkit repo when the user intended a consumer repo
Handoff
| Situation | Next |
|---|---|
| PLAN step with EF | Continue /sdd-develop - <full-plan-path> - Step N (path from implement handoff; SDD locations per STORAGE.md) |
| Build/test failures after migration | /repair-dotnet-build |
| Commit | /commit |
04 同仓库更多 Skills
user-own-skill
Operator-owned skill that is not part of the toolkit.
vue-developer
Implement or fix small-to-medium Vue 3 features without full SDD (Composition API, Pinia, configured project test runner; Vitest is a fallback for new projects). Use for isolated Vue work or when invoking /vue-developer.
test-coverage
Run .NET Coverlet coverage, report Sonar-aligned metrics, and evaluate against a threshold (default 80%). Use for coverage reports or when invoking /test-coverage.
split-story-checklist
Break refined backlog steps into a dependency-aware task checklist (backend, frontend, tests). Prefer features/... story folders. Use when breaking down tasks or invoking /split-story-checklist.
sdd-spec
Create a PRD for a new feature or change (agent PRD .md; language per LANGUAGE.md + preferences under features/). Feeds sdd-plan. Use when creating a spec or invoking /sdd-spec.
sdd-plan
Create a baby-step PLAN from an existing PRD (agent PLAN .md; language per LANGUAGE.md + preferences). Feeds sdd-develop. Use when creating a plan or invoking /sdd-plan.