diagnose-migration-history-divergencelisted
Install: claude install-skill justinmchoi/ai-toolkit
# Diagnose Migration-History Divergence
Use when an EF Core deploy or rollback against a **shared** environment
(not a personal dev DB) surfaces a `migration '<id>' was not found` error,
or before running `Update-Database` / `dotnet ef database update` against a
shared environment as a rollback. Either situation means the target's
`__EFMigrationsHistory` may contain migrations the current branch doesn't
know about.
## Why this is skill-shaped, not a one-off fix
Any team running EF Core migrations against a shared environment from
multiple parallel branches can hit "the environment has migrations the
current branch doesn't know about" — typically because someone applied an
unmerged branch's migrations directly to that environment, whether as a
deliberate shortcut or by accident. The failure mode shows up from two
different entry points that look unrelated at first:
- A **deploy pipeline** fails applying a new migration with a "migration
... was not found" error that's confusing on its face, since the named
migration usually isn't the one actually being deployed.
- A **planned rollback** (`Update-Database <id>` or equivalent) silently
targets the wrong point in history, or fails outright, because the
branch doing the rollback also doesn't contain the divergent migrations
sitting in the environment's history table.
Same root cause, same multi-step manual git trace, done by hand each time
regardless of which entry point surfaced it. The diagnostic sequence
generali