dotnet-ef-migrations

Generate and apply EF Core migrations for .NET 8+ database schema changes.

2|Updated Oct 24, 2025
One-click install
npx skills add https://github.com/onesmartguy/next-level-real-estate --skill dotnet-ef-migrations
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dotnet-ef-migrations
Source: https://github.com/onesmartguy/next-level-real-estate/tree/main/.claude/skills/database-migrations/skills/dotnet-ef-migrations
Command: npx skills add https://github.com/onesmartguy/next-level-real-estate --skill dotnet-ef-migrations

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires Microsoft.EntityFrameworkCore.Design, Microsoft.EntityFrameworkCore.SqlServer, Npgsql.EntityFrameworkCore.PostgreSQL.

What problem does it solve?

This Skill simplifies managing database schema changes in .NET applications using Entity Framework Core migrations, ensuring consistent and reliable database updates across environments. It helps you evolve your database schema in sync with your code, reducing deployment risks and manual errors.

Core Features & Use Cases

  • Code-First Migrations: Generate and apply migrations based on your C# DbContext, keeping your database schema in sync with your models.
  • Data Seeding & Custom SQL: Populate initial data and execute raw SQL commands within migrations for fine-grained control.
  • Production Deployment Strategies: Generate idempotent SQL scripts or migration bundles for safe, repeatable production deployments.
  • Rollback & Conflict Handling: Learn to revert migrations and resolve conflicts efficiently in team development environments.

Quick Start

Generate a new EF Core migration for my .NET application to add a new OrderStatus column to the Orders table, and then create an idempotent SQL script for production deployment.

Frequently Asked Questions about dotnet-ef-migrations

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

FAQPage Schema
How do I generate and apply EF Core migrations to update my database schema?

EF Core migrations let you evolve your database schema from C# code. Generate a migration with `dotnet ef migrations add`, review the generated migration file, then apply it with `dotnet ef database update`. This keeps your database in sync with your DbContext models across development and production environments.

Can I create idempotent SQL scripts from EF Core migrations for production deployment?

Yes. EF Core generates idempotent SQL scripts that safely run multiple times without errors. Use `dotnet ef migrations script` to create deployment-ready SQL, or bundle migrations with `dotnet ef migrations bundle` for self-contained, repeatable production rollouts without requiring EF Core tooling on the server.

How do I seed initial data and execute custom SQL within EF Core migrations?

Use the `HasData()` method in migration configurations to insert seed data, or call `migrationBuilder.Sql()` to execute raw SQL commands. This gives you fine-grained control over data population and schema customization during migration execution.

What's the best way to handle rollbacks and resolve migration conflicts in team environments?

Remove unpushed migrations with `dotnet ef migrations remove`, or revert applied migrations using `dotnet ef database update [previous-migration]`. For conflicts in shared code, coordinate with your team, remove conflicting migrations, and reapply them in the correct order to maintain a linear migration history.

Does EF Core migrations work with SQL Server and PostgreSQL databases?

Yes. EF Core migrations support both SQL Server and PostgreSQL through provider packages: `Microsoft.EntityFrameworkCore.SqlServer` for SQL Server and `Npgsql.EntityFrameworkCore.PostgreSQL` for PostgreSQL. Configure your DbContext with the appropriate provider to generate database-specific migration scripts.

Do I need special setup to use EF Core migrations in a .NET 8+ application?

Install the required NuGet packages: `Microsoft.EntityFrameworkCore.Design` for tooling, plus your database provider package. Configure your DbContext in your application, then use the `dotnet ef` CLI commands. The Design package enables migration scaffolding and script generation.