ef-migrations
Instructions for managing Entity Framework Core migrations using project scripts. Use when adding, removing, applying, or listing database migrations.
When & Why to Use This Skill
This Claude skill streamlines Entity Framework Core (EF Core) migration management by providing a standardized set of scripts for database schema versioning. It automates complex CLI commands for adding, applying, removing, and rolling back migrations, ensuring consistency across different operating systems (macOS, Linux, and Windows) and reducing manual errors in .NET database development.
Use Cases
- Automating the creation of new migrations after modifying C# domain models to ensure the database schema stays in sync with the application code.
- Executing database updates across different development environments using standardized Bash or PowerShell scripts to maintain schema parity.
- Safely removing pending migrations or rolling back the database to a specific historical state to recover from development errors or failed deployments.
- Simplifying the developer workflow by providing a unified, script-based interface that handles project paths and configurations automatically.
| name | ef-migrations |
|---|---|
| description | Instructions for managing Entity Framework Core migrations using project scripts. Use when adding, removing, applying, or listing database migrations. |
Entity Framework Core Migrations
This project uses shell scripts to manage EF Core migrations. These scripts handle project paths and configuration automatically.
Scripts Location
- Bash (macOS/Linux):
./scripts/bash/ - PowerShell (Windows):
./scripts/powershell/
Workflow
1. Create a New Migration
Use this when you have modified domain entities or configurations and need to update the database schema.
Bash:
./scripts/bash/db-migrate-add.sh <MigrationName>
PowerShell:
./scripts/powershell/db-migrate-add.ps1 <MigrationName>
2. Apply Migrations
Use this to update the database to match the current migrations.
Bash:
./scripts/bash/db-update.sh
PowerShell:
./scripts/powershell/db-update.ps1
3. Remove Last Migration
Use this if you created a migration by mistake and haven't applied it yet (or want to revert the code changes and the migration artifact).
Bash:
./scripts/bash/db-migrate-remove.sh
PowerShell:
./scripts/powershell/db-migrate-remove.ps1
4. List Migrations
Bash:
./scripts/bash/db-migrate-list.sh
PowerShell:
./scripts/powershell/db-migrate-list.ps1
5. Rollback Database
Use this to revert the database to a specific previous migration.
Bash:
./scripts/bash/db-migrate-rollback.sh <TargetMigrationName>
PowerShell:
./scripts/powershell/db-migrate-rollback.ps1 <TargetMigrationName>