ef-migration

Generates and applies EF Core migrations for SQLite schema changes in a .NET API.

Updated May 7, 2026
One-click install
npx skills add https://github.com/Pieter-1337/Euricom-tsz --skill ef-migration-pieter-1337
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ef-migration
Source: https://github.com/Pieter-1337/Euricom-tsz/tree/main/.claude/skills/tsz-ef-migration
Command: npx skills add https://github.com/Pieter-1337/Euricom-tsz --skill ef-migration-pieter-1337

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Changing an entity or its IEntityTypeConfiguration in a .NET API requires a matching database schema migration, and hand-writing migrations is error-prone. This Skill walks through the full EF Core migration workflow so schema changes are generated from the C# model, applied at startup, and committed correctly. ## Core Features & Use Cases - Migration Generation: Runs dotnet ef migrations add against the Tsz.Api project to produce Up/Down migration files, a Designer file, and an updated AppDbContextModelSnapshot. - SQLite-Specific Guidance: Flags table-rebuild behavior for DROP COLUMN and type changes, and shows how to add migrationBuilder.Sql(...) for data backfills on new NOT NULL columns. - Safe Rollback: Explains how to remove a not-yet-applied migration or roll back a locally applied one with dotnet ef database update. - Use Case: After adding a Colour field to the User entity, generate an AddColourToUser migration, backfill existing rows, restart the API so db.Database.Migrate() applies it, and commit the snapshot. ## Quick Start Add an EF Core migration for the entity change I just made in packages/api and apply it to the local SQLite database.

Frequently Asked Questions about ef-migration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create an EF Core migration with dotnet ef?

Run `dotnet ef migrations add <Name> --project packages/api/Tsz.Api --startup-project packages/api/Tsz.Api --output-dir Persistence/Migrations` from the repo root. This generates the migration file, a Designer file, and updates AppDbContextModelSnapshot.cs, which must be committed.

How do I apply EF Core migrations to a SQLite database?

Migrations apply automatically at API startup via db.Database.Migrate() in Program.cs. To apply without starting the API, run `dotnet ef database update` with the project and startup-project flags. Stop the running API first since the tsz.db file will be locked.

How do I backfill data when adding a NOT NULL column in EF Core?

EF Core only generates DDL, so hand-edit the migration to add a `migrationBuilder.Sql("UPDATE ...")` call between the AddColumn step and later steps. Mirror the backfill logic in the Down() method for rollback.

Why is my SQLite migration so large after dropping a column?

SQLite cannot drop columns or alter constraints directly, so EF emulates it by creating a new table, copying data, dropping the old table, and renaming. The migration is large but correct; with lots of data, consider whether the change is worth it.

How do I revert an EF Core migration that was already applied?

First roll back the database with `dotnet ef database update <PreviousMigrationName>`, then run `dotnet ef migrations remove`. Never edit a migration that has already been applied to any environment; generate a new one instead.