/database-sqlserver:migration-troubleshootfrom database-sqlserver
Use when diagnosing special EF Core migration situations — ModelSnapshot 衝突、歷史紀錄遺失、資料庫已套用但 migration 對不上、生產緊急回滾判斷。一般失敗修復循環走 ef-migration skill。觸發:「migration 對不上」「snapshot 衝突」「緊急回滾」「migration 診斷」。
Ships in database-sqlserver. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
職責邊界:
- 一般 migration flow(建立 / 套用 / 回復 / 失敗修復)→
ef-migrationskill- 特殊診斷情境(本 skill)→ ModelSnapshot 衝突、歷史遺失、生產緊急回滾
共用參數(依專案調整 project 路徑與 sln 名稱):
EF_ARGS="--project src/YourApp.Domain --startup-project src/YourApp.Domain"
| 症狀 | 可能原因 | 診斷指令 |
|---|---|---|
| Migration 無法建立 | 建置失敗 | dotnet build YourApp.sln -c Release |
| Migration 套用失敗 | SQL 錯誤 | dotnet ef database update --verbose $EF_ARGS |
| ModelSnapshot 衝突 | 多人並行開發 | 檢查 git 衝突 |
| 資料庫狀態不明 | 手動修改資料庫 | dotnet ef migrations list $EF_ARGS |
| Factory log 顯示連錯 host | 連線 CLI args / env var 設錯 | 檢查連線注入參數 |
git stash # 保存你的變更
git pull # 拉最新
dotnet ef migrations remove $EF_ARGS # 移除你的 migration
git stash pop # 還原變更
dotnet ef migrations add {NewName} $EF_ARGS --context AppDbContext
dotnet ef migrations add EmptySync $EF_ARGS # 建立空 migration
# 手動清空 Up() 和 Down()
dotnet ef database update $EF_ARGS # 只寫 __EFMigrationsHistory
走 ef-migration skill 的失敗修復段(讀錯誤、修 .cs、重跑,不用 migrations remove)。
回滾指令見 ef-migration skill。本 skill 補充診斷檢查清單:
Down() 方法正確dotnet ef migrations script {from} {to} $EF_ARGS --output rollback.sql)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub kerryhuang/kerryhuang-plugins --plugin database-sqlserver6 skills in this plugin
/ef-migrationUse when 建立 / 套用 / 回復 EF Core migration、跑 `dotnet ef` 指令、切換目標資料庫連線、migration 失敗診斷。管理 SQL Server 上的 Entity Framework Core 資料庫 Migration。觸發:「建 migration」「套用 migration」「回滾 migration」「dotnet ef」「migration 失敗」。/generating-table-descriptionUse when generating table description documentation from SQL view files. Use when user says "產生資料表描述", "文件化檢視表", "更新 TableDescription", "由 view 產欄位對照". Use when user wants to document view-to-table field mappings for a SQL Server database./syncing-db-entitiesUse when adding new DB tables/views to an EF Core project, syncing entity changes from the database, fixing Entity precision / nullable / MaxLength that drifted from the DB actual schema, or user says "加表", "同步 Entity", "scaffold", "efcpt", "更新實體", "re-scaffold", "重新產生 Entity". Also trigger when reading a file with header `// <auto-generated> This file has been auto generated by EF Core Power Tools.` that needs modification — manual edits will be overwritten, must go through efcpt.Other plugins' skills for the same job