Without migrations you need to create a lots of sql scripts that have to be run manually by every developer involved. Migrations solve the problem of evolving a database schema for multiple databases (for example, the developer's local database, the test database and the production database).
$ dotnet add package Curiosity.MigrationsCuriosity.Migrations is a powerful, flexible database migration framework for .NET and .NET Core applications that gives you precise control over how your database evolves. It combines the performance and control of raw SQL with the flexibility of C# code migrations, all wrapped in a robust, enterprise-ready migration system.
Unlike ORM-specific migration tools, Curiosity.Migrations is database-focused and designed for scenarios where you need fine-grained control over migration execution, especially for large production databases where performance and safety are critical.
🔧 Precise ControlWrite raw SQL when you need optimal performance, or use C# code when you need complex logic. You control exactly what runs against your database. |
🚀 Production-ReadyBuilt for enterprise applications with safety features, long-running migration support, and granular policies to control what runs in each environment. |
🔄 BidirectionalFirst-class support for downgrade migrations enables safe rollbacks when deployments don't go as planned. |
📊 Progressive MigrationsSeparate long-running data migrations from quick schema changes to keep your application responsive during upgrades. |
🧪 TestabilityCreate and initialize test databases with specific migration states for reliable integration testing. |
🧩 ExtensibilityCustomize where migrations come from, how they're logged, and how they're applied to fit your workflow. |
Script Migrations: Write raw SQL for direct database access
Code Migrations: Implement migrations in C# for complex scenarios
# Install core package
dotnet add package Curiosity.Migrations
# Install database provider (PostgreSQL or SQL Server)
dotnet add package Curiosity.Migrations.PostgreSQL
# or
dotnet add package Curiosity.Migrations.SqlServer
// Configure the migration engine
var builder = new MigrationEngineBuilder(services)
.UseScriptMigrations().FromDirectory("./Migrations") // Add SQL migrations
.UseCodeMigrations().FromAssembly(Assembly.GetExecutingAssembly()) // Add code migrations
.ConfigureForPostgreSql("Host=localhost;Database=myapp;Username=postgres;Password=secret")
.UseUpgradeMigrationPolicy(MigrationPolicy.AllAllowed);
// Build and run the engine
var migrationEngine = builder.Build();
var result = await migrationEngine.UpgradeDatabaseAsync();
// Check results
if (result.IsSuccessful)
{
Console.WriteLine($"Successfully migrated");
}
Get started quickly with the Quick Start Guide or dive into Core Concepts.
PostgreSQL |
SQL Server |
Support for additional databases can be added through contributions.
| Feature | Curiosity.Migrations | EF Core Migrations | FluentMigrator | DbUp |
|---|---|---|---|---|
| Direct SQL Control | ✅ Full | ⚠️ Generated | ⚠️ Generated | ✅ Full |
| Code Migrations | ✅ Native | ⚠️ Limited | ⚠️ Via API | ❌ No |
| Downgrade Support | ✅ First-class | ⚠️ Limited | ⚠️ Limited | ❌ No |
| Long-running Migrations | ✅ Optimized | ❌ No | ❌ No | ❌ No |
| Migration Policies | ✅ Configurable | ❌ No | ❌ No | ❌ No |
| DI Support | ✅ Native | ⚠️ Limited | ⚠️ Limited | ⚠️ Basic |
| Best For | Enterprise apps, complex migrations, performance-critical systems | Simple CRUD apps with EF Core | Cross-database projects | Simple script runners |
For more detailed comparisons, see The Philosophy Behind Curiosity.Migrations.
| Package | Version | Downloads |
|---|---|---|
| Curiosity.Migrations | ||
| Curiosity.Migrations.PostgreSQL | ||
| Curiosity.Migrations.SqlServer | ||
| Curiosity.Migrations.Utils |
Curiosity.Migrations is licensed under the MIT License.