EF Core — workflow de migrationsEF Core — migration workflow
Le skill /efcore couvre le cycle de vie complet des migrations Entity Framework Core sur un projet généré SmartStack (dual context : CoreDbContext + ExtensionsDbContext) ou sur le Studio (single context, providers Sqlite / Postgres / SqlServer). Au quotidien : /efcore create puis /efcore apply ; jamais dotnet ef en direct, le hook ef-guard le bloque.
The /efcore skill covers the full Entity Framework Core migration lifecycle on a generated SmartStack project (dual context: CoreDbContext + ExtensionsDbContext) or on the Studio (single context, Sqlite / Postgres / SqlServer providers). Day to day: /efcore create then /efcore apply; never raw dotnet ef, the ef-guard hook blocks it.
Routing des opérationsOperation routing
Chaque intention a son agent et son CLI : Each intent has its agent and its CLI:
Voir le détail : agent et CLI par opérationShow details: agent and CLI per operation
| IntentionIntent | Agent | CLI |
|---|---|---|
| Lister les migrationsList migrations | agents/list.md |
cli/list |
| État (pending / applied)Status (pending / applied) | agents/status.md |
cli/status |
| Créer une migrationCreate a migration | agents/create.md |
cli/create |
| Compresser avant mergeSquash before merge | agents/squash.md |
cli/squash |
| Rebase snapshotRebase snapshot | agents/rebase-snapshot.md |
cli/rebase-snapshot |
| Appliquer (dotnet ef database update)Apply (dotnet ef database update) | agents/db-update.md |
cli/apply |
| Recréer la base de zéroRecreate the database from scratch | agents/recreate-db.md |
— |
Convention de nommageNaming convention
Toutes les migrations suivent le pattern {prefix}v{version}{seq3}{Description}, calculé par cli/lib/migration-name.ts :
All migrations follow the pattern {prefix}v{version}{seq3}{Description}, computed by cli/lib/migration-name.ts:
Core_v5_0_0_001_AddInitialSchema
Ext_v5_0_0_002_AddInvoiceTable
Voir le détail : source de chaque tokenShow details: source of each token
| TokenToken | SourceSource |
|---|---|
prefix |
Core / Ext / Sqlite / Postgres / SqlServer |
version |
version du projet — package.json (source de vérité GitFlow), sinon .csprojproject version — package.json (GitFlow source of truth), else .csproj |
seq3 |
numérotation séquentielle à 3 chiffres3-digit sequential numbering |
Description |
PascalCasePascalCase |
Détection automatiqueAutomatic detection
Le CLI détecte automatiquement la structure : The CLI auto-detects the structure:
- App générée : 2 contextes, 2 fichiers de migrations.Generated app: 2 contexts, 2 migration files.
- Studio : 1 contexte, 3 projets de migrations (un par provider).Studio: 1 context, 3 migration projects (one per provider).
Plus aucune dépendance MCP — cli/lib/ef-runner.ts appelle dotnet ef directement.
No more MCP dependency — cli/lib/ef-runner.ts calls dotnet ef directly.
Dans quel cas ?Which situation, which command?
| Je suis dans ce cas…I am in this situation… | …alors je fais…then I do |
|---|---|
| J'ai ajouté/modifié une entité et je veux la refléter en baseI added/changed an entity and want it reflected in the database | /efcore create — le nom est calculé automatiquement selon la convention/efcore create — the name is computed automatically per the convention |
| Ma base de travail est en retard sur les migrations du codeMy working database is behind the code's migrations | /efcore apply — appliqué seul si la base est ta base de travail : nommée dans appsettings.Local.json sur une branche feature/ (quel que soit l'hôte), ou prouvée locale (loopback, hostname machine, efcore.localHosts)/efcore apply — applied autonomously only when the database is your working database: named in appsettings.Local.json on a feature/ branch (whatever its host), or proven local (loopback, machine hostname, efcore.localHosts) |
| Ma feature a accumulé 12 migrations avant le mergeMy feature piled up 12 migrations before the merge | /efcore squash — consolide UNIQUEMENT les migrations propres à la branche, jamais une migration déjà présente dans la branche cible/efcore squash — consolidates ONLY the branch's own migrations, never one already present in the target branch |
| Je ne sais plus ce qui est appliqué ou en attenteI no longer know what is applied or pending | /efcore status |
| Le snapshot EF est en conflit après un mergeThe EF snapshot conflicts after a merge | /efcore rebase-snapshot |
| Ma base de dev est irrécupérable, je repars de zéroMy dev database is beyond repair, I start over | /efcore recreate-db (destructif — demande confirmation)/efcore recreate-db (destructive — asks for confirmation) |
⚠️ N'appelez jamais dotnet ef directement dans le shell : le hook ef-guard le bloque. Le chemin sanctionné est /efcore, qui applique la politique de risque (une migration destructive exige une confirmation explicite ; un apply refusé n'a pas de jeton — l'enveloppe dit comment le lever).
⚠️ Never call dotnet ef directly in the shell: the ef-guard hook blocks it. The sanctioned path is /efcore, which enforces the risk policy (a destructive migration requires explicit confirmation; a refused apply has no token — the envelope says how to lift it).
Quelle base ? La provenance avant la topologieWhich database? Provenance before topology
/efcore apply classe d'abord quelle couche de configuration a nommé la base (configSource dans l'enveloppe), dans l'ordre où l'application elle-même la résout : variable d'environnement > appsettings.Local.json > appsettings.Development.json > appsettings.json. appsettings.Local.json est gitignoré et seedé par branche par ss dev configure : c'est par construction la base de travail du développeur.
/efcore apply first classifies which configuration layer named the database (configSource in the envelope), in the order the app itself resolves it: environment variable > appsettings.Local.json > appsettings.Development.json > appsettings.json. appsettings.Local.json is gitignored and seeded per branch by ss dev configure: by construction it is the developer's working database.
| ProvenanceProvenance | HôteHost | BrancheBranch | VerdictVerdict |
|---|---|---|---|
| n'importe laquelleany | loopback, hostname machine, efcore.localHostsloopback, machine hostname, efcore.localHosts |
touteany | 🟢 |
appsettings.Local.json |
autre (LAN, 10.x, Azure SQL)other (LAN, 10.x, Azure SQL) |
feature/* |
🟢 — journalisé dans .claude/Efcore-history/🟢 — journaled under .claude/Efcore-history/ |
appsettings.Local.json |
autreother | develop / release/* / hotfix/* |
🟡 confirm — base d'intégration🟡 confirm — an integration database |
variable d'environnement ConnectionStrings__DefaultConnectionConnectionStrings__DefaultConnection environment variable |
— | touteany | 🔴 — contexte de déploiement🔴 — a deployment context |
fichier committé (appsettings.json, .Development.json), ou aucune chaînecommitted file (appsettings.json, .Development.json), or no string |
non localnon-local | touteany | 🔴 |
Voir le détail : le 🔴 sans jeton, le bloc remediation et dryRunShow details: the token-less 🔴, the remediation block and dryRun
Le 🔴 n'a pas de jeton : confirm ne le lève jamais. L'enveloppe porte un bloc remediation (confirmable: false, kind, message) qui nomme la sortie structurelle — nommer sa base dans appsettings.Local.json, retirer une variable d'environnement de déploiement, ou déployer l'application, qui applique elle-même ses migrations au démarrage. Ces décisions appartiennent à l'utilisateur, jamais à l'agent. "dryRun": true mesure sur tous les paliers (avant la politique) : configSource, migrations en attente par contexte, wouldApply.
A 🔴 carries no token: confirm never lifts it. The envelope carries a remediation block (confirmable: false, kind, message) naming the structural exit — name your database in appsettings.Local.json, unset a deployment environment variable, or deploy the app, which applies its own migrations at startup. Those decisions belong to the user, never to the agent. "dryRun": true measures on every tier (before the policy): configSource, pending migrations per context, wouldApply.
Skills de cette page
Skills on this page
infrastructure 1
-
/efcoreEF Core migration workflow — create, squash, rebase-snapshot, apply, list, status.[create|squash|rebase-snapshot|apply|list|status|recreate-db] [-BruteForce]
Aucun skill ne correspond.No skill matches.