Curiosity.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.
|
Write raw SQL when you need optimal performance, or use C# code when you need complex logic. You control exactly what runs against your database. |
Built for enterprise applications with safety features, long-running migration support, and granular policies to control what runs in each environment. |
|
First-class support for downgrade migrations enables safe rollbacks when deployments don't go as planned. |
Separate long-running data migrations from quick schema changes to keep your application responsive during upgrades. |
|
Create and initialize test databases with specific migration states for reliable integration testing. |
Customize 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
- Batched Execution: Split large scripts into manageable chunks
- Full support for database-specific SQL features and optimizations
-
Code Migrations: Implement migrations in C# for complex scenarios
- Dependency Injection: Use your application's services in migrations
- Entity Framework Integration: Leverage EF Core when needed
- Implement custom validation, logging, or business logic during migrations
- Policies: Control which migrations run in different environments
- Dependencies: Specify explicit requirements between migrations
- Downgrade Migrations: Safely roll back changes when needed
- Transactions: Configure transaction behavior per migration
- Long-running vs Short-running: Separate quick schema changes from data-intensive operations
- Migration Providers: Source migrations from files, embedded resources, etc.
- Variables: Dynamic value substitution in migrations
- Pre-migrations: Run setup scripts before main migrations
- Custom Journal: Configure how applied migrations are tracked
# 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 | β Full | ||
| Code Migrations | β Native | β No | ||
| Downgrade Support | β First-class | β No | ||
| Long-running Migrations | β Optimized | β No | β No | β No |
| Migration Policies | β Configurable | β No | β No | β No |
| DI Support | β Native | |||
| 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 |
- GitHub Issues - Report bugs or request features
- GitHub Discussions - Ask questions and discuss ideas
Curiosity.Migrations is licensed under the MIT License.
