Skip to main content

Curiosus.Migrations

Database migration framework for .NET: raw SQL and C# code migrations, downgrades, long-running data migrations and per-environment policies for PostgreSQL and SQL Server.

Build License NuGet Downloads Coverage Docs

Renamed: formerly Curiosity.Migrations* by SIIS Ltd. Since 5.0.0 the packages are published as Curiosus.Migrations* by curiosus-dev. To migrate, replace Curiosity with Curiosus in package references and code. -- CURIOSITY: directives in SQL scripts keep working.

Why use itโ€‹

Curiosus.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, Curiosus.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 Control

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.

๐Ÿš€ Production-Ready

Built for enterprise applications with safety features, long-running migration support, and granular policies to control what runs in each environment.

๐Ÿ”„ Bidirectional

First-class support for downgrade migrations enables safe rollbacks when deployments don't go as planned.

๐Ÿ“Š Progressive Migrations

Separate long-running data migrations from quick schema changes to keep your application responsive during upgrades.

๐Ÿงช Testability

Create and initialize test databases with specific migration states for reliable integration testing.

๐Ÿงฉ Extensibility

Customize where migrations come from, how they're logged, and how they're applied to fit your workflow.

Featuresโ€‹

Migration Typesโ€‹

Safety and Controlโ€‹

Extensibilityโ€‹

Quick startโ€‹

Installationโ€‹

# Install core package
dotnet add package Curiosus.Migrations

# Install database provider (PostgreSQL or SQL Server)
dotnet add package Curiosus.Migrations.PostgreSQL
# or
dotnet add package Curiosus.Migrations.SqlServer

Basic Setupโ€‹

// 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.IsSuccessfully)
{
Console.WriteLine($"Successfully migrated");
}

Get started quickly with the Quick Start Guide or dive into Core Concepts.

Supported Databasesโ€‹


PostgreSQL

SQL Server

Support for additional databases can be added through contributions.

Comparing with Alternativesโ€‹

FeatureCuriosus.MigrationsEF Core MigrationsFluentMigratorDbUp
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 ForEnterprise apps, complex migrations, performance-critical systemsSimple CRUD apps with EF CoreCross-database projectsSimple script runners

For more detailed comparisons, see The Philosophy Behind Curiosus.Migrations.

Available packagesโ€‹

PackageVersionDownloadsCoverage
Curiosus.MigrationsNuGetNuGetCoverage
Curiosus.Migrations.PostgreSQLNuGetNuGetCoverage
Curiosus.Migrations.SqlServerNuGetNuGetCoverage
Curiosus.Migrations.UtilsNuGetNuGetCoverage

Supportโ€‹

Licenseโ€‹

Curiosus.Migrations is licensed under the MIT License.