DOTNETPROJECTS / DATABASE MIGRATIONS

Database changes,
written in C#.

A table today. A different table tomorrow. Keep every change explicit, versioned, and close to your application.

Choose Classic or Fluent migrations. Bring your ADO.NET driver. Run the same migration system alongside any ORM—or without one.

ONE CHANGE. TWO WAYS TO WRITE IT.001 ↘
CreateUsers.cs

Classic

using System.Data;
using DotNetProjects.Migrator.Framework;

[Migration(1)]
public class CreateUsers : Migration
{
    public override void Up()
    {
        Database.AddTable("Users",
            new Column("Id", DbType.Int32) { IsNullable = false },
            new Column("Name", DbType.String, 255),
            new PrimaryKeyConstraint("PK_Users", "Id"));
    }

    public override void Down() => Database.RemoveTable("Users");
}

Fluent

using DotNetProjects.Migrator.Framework;
using DotNetProjects.Migrator.Framework.Fluent;

[Migration(1)]
public class CreateUsers : FluentMigration
{
    public override void BuildUp(MigrationBuilder migration)
    {
        migration.Create.Table("Users")
            .WithColumn("Id").AsInt32().NotNullable()
            .WithColumn("Name").AsString(255)
            .WithPrimaryKey("PK_Users", "Id");
    }

    public override void BuildDown(MigrationBuilder migration)
        => migration.Delete.Table("Users");
}

Choose one authoring style

01 / AUTHORWrite a numbered change.

02 / REVIEWPlan the next step.

03 / APPLYLeave a lasting record.

SMALL PRIMITIVES. REAL DATABASES.

Your schema.
Your decisions.

01

Two C# styles

Classic provider calls or a Fluent builder. Tables, columns, indexes, constraints, views, guard and audit triggers, and data queries.

Compare the APIs ↗
02

A deliberate deployment

Version plans, tags, profiles, maintenance stages, transaction modes and native locks. A CLI or a runner inside your own host.

Choose a runner ↗
03

History with boundaries

Track applied versions and give modules separate histories through scopes. Author the reverse for changes that need it.

Understand versioning ↗

A PARTICULAR STRENGTH / SQLITE

A small database.
Room to evolve.

Change the schema you have. Without an ORM model.

Migrator reads SQLite’s live schema and automatically reconstructs tables for supported changes to column types, defaults and nullability, and primary, foreign, unique and check constraints.

Existing rows are copied and supported schema artifacts are preserved. You describe the change; the provider handles the rebuild.

FluentMigrator requires manual reconstruction for general column alterations and later foreign-key changes. DbUp and Evolve leave it to your scripts. EF Core also rebuilds tables, using model metadata.

Read the SQLite guide and preservation limits ↗
See the sourced operation comparison →
TABLE / UsersΔ 002

IdINTEGER · PRIMARY KEY

Name255 500 · NOT NULL

↳ Existing rows travel with the schema.

Change a column on an existing SQLite table

Classic

Database.ChangeColumn("Users", new Column("Name", DbType.String, 500)
{
    IsNullable = false, DefaultValue = "Unknown",
    Collation = Collation.AsciiIgnoreCase
});

Fluent

migration.Alter.Column("Name").OnTable("Users")
    .AsString(500).NotNullable().WithDefaultValue("Unknown")
    .WithCollation(Collation.AsciiIgnoreCase);

Inside Up() / BuildUp(MigrationBuilder migration)

FROM EMPTY FOLDER TO FIRST TABLE

Start with
one change.

Install the library and your database driver. Add the migration above, wire up the runner, and apply it. SQLite makes a convenient first database.

Follow the complete quick start ↗
Terminal · either authoring style

Classic

dotnet new console -n MigrationDemo -f net9.0
cd MigrationDemo
dotnet add package DotNetProjects.Migrator
dotnet add package Microsoft.Data.Sqlite --version 9.0.7

Fluent

dotnet new console -n MigrationDemo -f net9.0
cd MigrationDemo
dotnet add package DotNetProjects.Migrator
dotnet add package Microsoft.Data.Sqlite --version 9.0.7

Shared commands · both styles

THE MIGRATION MANUAL

Past “hello, table.”

Detailed guides, paired examples, and provider notes.
Browse every chapter ↗

BRING YOUR DATABASE

One migration system.
Many dialects.

Capabilities follow the database engine. The provider guide explains aliases, drivers and operation-specific behavior.

TEST RESULTS AND CODE COVERAGE

Evidence from CI.

The CI matrix runs unit tests and 11 database suites, then checks for missing or duplicate test assignments. Counts represent test executions across the matrix; skipped tests are shown separately. Line and branch coverage measure production code across the combined suites.

Code coverage

Production assemblies, merged across unit and database suites; shared code is counted once. Download the full HTML coverage report ↗ (code-coverage artifact; open index.html).

CI run · a0a9ae0 · 2026-11-23T11:57:56Z · workflow: success. Latest completed master run at deployment time.

THE .NET MIGRATION LANDSCAPE

Choose by how you work.

Workflows reviewed 23 September 2026
Schema features and OrmLite/grate reviewed 22 November 2026
Read the sources and qualifications ↓

Use fluent operations, version planning, a SQL-preview subset, runner options, native locks and the CLI. Read the runner guide and provider limits.

Migrator fits applications that want explicit C# migrations and scoped history without coupling schema changes to an ORM. Other tools offer different authoring and deployment workflows.

Read the detailed feature comparison (Markdown) →
Explore SQLite emulation, preservation limits and framework differences →

Scroll horizontally to compare all seven frameworks on smaller screens.

Built-in capabilities and documented workflows. ✓ means dedicated API support; ✗ means raw SQL or custom code is required. Provider limits apply to every framework.
Capability Migrator.NET Classic + Fluent APIsSource [1] FluentMigrator Sources [2] EF Core Sources [3] DbUp Sources [4] Evolve Sources [5] OrmLite Sources [6] grate Sources [7]
Authoring style Classic provider API + Fluent migration builder Handwritten C#
Fluent DSL
C# generated from model changes; editable SQL scripts; C# scripts also supported Versioned SQL files C# Up/Down; typed schema APIs and declarative model attributes SQL scripts in ordered folders
ORM-independent workflow Yes Yes Uses EF model and DbContext Yes Yes Uses OrmLite models and connections; no EF dependency Yes
Generate migrations from model differences No built-in generator Hand-authored Yes — model snapshots Hand-authored Hand-authored ✓ Live database/model diff; generates reviewable C# migrations ✗ Hand-authored scripts
Raw SQL ✓ ExecuteNonQuery / fluent Execute.Sql / scripts ✓ Execute.Sql / scripts ✓ migrationBuilder.Sql ✓ Primary workflow ✓ Primary workflow ✓ Db.ExecuteSql / custom SQL hooks ✓ Primary workflow
Downgrade an applied version Authored Down() or supported automatic reversal Down(); auto-reverse for supported expressions Down(); target an earlier migration Forward fixes; custom undo workflow Forward fixes; no Down command Authored Down(); runner revert commands Forward fixes; no automatic Down migrations
History / module separation Scope-filtered discovery + history Custom version tables + migration filtering Separate contexts / migrations + custom history tables Separate journals + script filtering Metadata table/schema + script locations Named connections; migration history in the primary database Configurable tracking schema and script folders; repository/version labels
Transactions Per migration by default; none or whole session (SQLite, PostgreSQL, SQL Server) Per migration by default; configurable Most migrations wrapped automatically Opt-in per script or whole run; none by default Per migration by default; whole-run option Per migration; database DDL limits apply Opt-in migration transaction; SQL Server/PostgreSQL support; other reviewed providers disable it
Execution / deployment Library + CLI In-process runner + CLI CLI, SQL scripts, bundles, runtime API Library; host in a console app or application .NET library, .NET tool, CLI Library + AppTasks / application host CLI, .NET tool, self-contained executable and Docker
Database abstraction Provider dialects for schema operations Provider-specific SQL generators Relational providers; migrations may differ by provider Database integrations; you write dialect-specific SQL Database integrations; you write dialect-specific SQL Typed model/schema/query APIs with provider dialects Database integrations; you write dialect-specific SQL
Repeatable / recurring work Ordered maintenance + named profiles; no checksum repeatables Maintenance migrations / profiles Seeding APIs (EF 9+); custom code RunAlways scripts Repeatable SQL reruns on checksum change Explicit migration reruns/reverts; custom recurring work Anytime scripts on hash changes; Everytime scripts each run
Automatic SQLite reconstruction ✓ Live-schema rebuilds; no ORM model ✗ Manual for general column and foreign-key alterations ✓ Rebuilds for model-represented artifacts ✗ Author scripts ✗ Author scripts ✓ Model-based schema-diff rebuilds; RebuildTable API ✗ Author scripts
Planning and SQL preview Read-only version plan; connected/offline SQL subset Preview/output Generated SQL scripts Authored SQL / pending scripts Authored SQL Schema diff with SQL and C# migration output; model-based Authored SQL + --dryrun / up-to-date check
Deployment coordination Opt-in native locks: SQL Server, PostgreSQL, MySQL/MariaDB Application-lock pattern / deployment orchestration Migration locking; execution-path dependent Host/provider concern Cluster setting; provider-dependent In-progress history/timeout check; serialize deployments externally External deployment coordination
Schema, triggers and data operations
Create / drop tablesStructured table definitions and lifecycle operations.✓✓✓✗✗✓✗
Rename tablesNative DDL or provider emulation; OrmLite exposes column rename but no dedicated table-rename API.✓✓✓✗✗✗✗
Rename columnsNative DDL or provider emulation; engine restrictions apply to every framework.✓✓✓✗✗✓✗
Change column type, default or nullabilityConversion and preservation rules depend on the provider.✓✓✓✗✗✓✗
Primary / foreign keysDedicated key definitions on applicable providers.✓✓✓✗✗✓✗
Composite primary keysMulti-column primary keys; OrmLite models require a single primary key.✓✓✓✗✗✗✗
Composite foreign keysMulti-column references; OrmLite's reviewed foreign-key API maps one field at a time.✓✓✓✗✗✗✗
Composite unique constraints / indexesEnforce uniqueness across a group of columns.✓✓✓✗✗✓✗
Filtered indexes / conditional uniquenessProvider-specific filters and index options are not universal engine capabilities.✓✓✓✗✗✓✗
Conditional guard triggersA reusable definition rejects writes when its predicate matches.✓✗✗✗✗✗✗
Related-row EXISTS guard rulesCorrelate affected rows with related tables without writing a trigger body.✓✗✗✗✗✗✗
Null-safe OLD / NEW change predicatesCompose change rules, including null transitions and negation.✓✗✗✗✗✗✗
Atomic multirow guard enforcementReject the whole statement if any affected row violates the guard.✓✗✗✗✗✗✗
Transactional JSON audit triggersRecord keys, operation, UTC time and previous values through a dedicated API.✓✗✗✗✗✗✗
Conditional auditing / selected JSON fieldsFilter audit events and declare the fields in each snapshot.✓✗✗✗✗✗✗
General declarative trigger actionsArbitrary actions such as dependent-row updates require SQL or custom code; dedicated guard and audit APIs are compared above.✗✗✗✗✗✗✗
Structured stored-procedure / function definitionsA dedicated definition API, rather than executing a hand-written SQL body.✗✗✗✗✗✗✗
Filtered view query + lifecycle APIStructured view creation, replacement and removal.✓✗✗✗✗✗✗
View queries with joins / correlated predicatesInner/left joins, aliases, grouped predicates and correlated EXISTS.✓✗✗✗✗✗✗
Portable binary byte-length CHECK rulesA typed expression translates byte-length semantics for the selected provider.✓✗✗✗✗✗✗
Portable JSON validity / shape CHECK rulesTyped JSON validation and array/object checks on applicable providers.✓✗✗✗✗✗✗
Projected INSERT … SELECTExplicit target mapping and server-side data movement through a query API.✓✗✗✗✗✓✗
CASE / COALESCE in data projectionsCompose defaults and conditional projected values without a SQL string.✓✗✗✗✗✓✗
Partitioned ROW_NUMBER projectionsWindow numbering inside the migration query API; deterministic ordering is required.✓✗✗✗✗✓✗
Ordered / limited / anti-join data selectionBuild ordered seeds and NOT EXISTS selection on the server.✓✗✗✗✗✓✗
SQLite rebuild preservation of views / triggersLive-schema preservation, dependency validation and savepoint rollback, including external and TEMP objects.✓✗✗✗✗✗✗

One rule for every framework: ✓ means a dedicated framework API implements the feature on applicable providers. A missing database capability does not remove the framework's checkmark. ✗ means there is no dedicated API in the reviewed core/provider packages; authoring raw SQL or custom code does not earn a check for that feature. SQL execution is compared in its own row.

Classic + Fluent: Migrator.NET exposes the schema, guard, audit, CHECK, view and projected-data operations above through both provider calls and the fluent migration builder. Provider support, engine versions, data types and DDL transaction rules still apply. See the portable API and provider qualifications and provider guide.

Schema feature sources reviewed 22 November 2026: Migrator APIs; FluentMigrator schema builders, filtered indexes and SQL execution; EF Core migration operations, views and triggers through SQL and SQLite preservation limits; DbUp; Evolve. OrmLite migrations, schema APIs, indexes and constraints, key limitations, schema diff and rebuilds, window functions and INSERT … SELECT API; grate SQL runner and configuration. Third-party extensions are outside this comparison.

Scope: OrmLite migrations directly expose the OrmLite connection and its schema/query APIs; those built-in APIs count here. EF Core is compared through MigrationBuilder, not an additional DbContext supplied by application code. OrmLite's generic CHECK SQL and custom view/trigger hooks do not count as typed portable definitions. Its SQLite rebuild preserves the rebuilt table's triggers and indexes, but the final row also requires external/TEMP dependency handling and validation. grate's trigger/view/procedure folders organize SQL scripts, rather than provide definition APIs.

Possible next additions — ideas, not commitments

Guard and JSON audit triggers, structured views, typed CHECK rules and projected INSERT queries are already implemented above. The remaining ideas would extend those APIs:

  • ☐ General declarative trigger actions, such as updating dependent rows, beyond the existing guard and audit definitions.
  • ☐ Expression-based UPDATE projections with joins and explicit row-pairing guarantees, beyond the existing column-copy UpdateTable/Match API.
  • ☐ Structured stored-procedure and function definitions with provider translations, beyond executing their SQL directly.
  • ☐ Migration-content checksum validation and checksum-driven repeatables, beyond version history and maintenance hooks.
  • ☐ Schema comparison that generates migration operations, beyond explicit migrations and the current version plan.

These are unimplemented proposals, not a release roadmap or supported feature checkmarks.

Rollback has two meanings. Reversing an already applied migration uses authored reverse operations. Rolling back a failed transaction depends on the database’s DDL support. Neither restores data removed by a successful destructive migration.

Recurring work is not the same as change detection. Evolve stores script checksums and validates changes; Migrator records versions and scopes without built-in content checksum validation. Maintenance hooks, seeding and RunAlways have different execution rules.

Keep migrations in C#

Migrator: imperative and fluent schema operations, scoped history, tags/profiles, and the CLI or your own host. FluentMigrator: a fluent DSL with packaged runners, tags and profiles. OrmLite: typed model/schema APIs and explicit Up/Down migrations.

Let the model drive changes

EF Core: a natural fit when an EF model defines your schema and you want migration scaffolding, SQL generation and deployment bundles.

Keep SQL as the source

DbUp: compose a script runner in .NET. Evolve: convention-based versioned SQL, checksum validation and repeatable scripts. grate: ordered SQL folders, hash-driven anytime scripts and everytime scripts.

Sources & comparison methodology

Our column is based on the current repository source, which targets net9.0. Other columns summarize official documentation reviewed on 22 September 2026, with SQLite comparisons rechecked on 23 September, rather than claiming parity across every released package. The schema-operation rows have a separate source review dated 22 November 2026, linked immediately below the table. Check your chosen release, provider and database version. OrmLite and grate workflow/API sources were reviewed on 22 November 2026. Suitability notes are our interpretation of these documented capabilities.

  1. DotNetProjects.Migrator: target framework, runner, execution and transactions, history and schema operations, migration discovery.
  2. FluentMigrator: quick start and runners, configuration and version tables, auto-reversing migrations, maintenance migrations, profiles, SQLite generator, authoring and providers.
  3. EF Core: model snapshots, authoring and transactions, scripts, bundles and downgrade, custom history tables, multiple providers, seeding, SQLite rebuilds and locking.
  4. DbUp: execution, transactions, journaling, script types, forward-change philosophy, SQL and C# script providers.
  5. Evolve: commands, checksums, repeatables and transactions, configuration, execution options.
  6. ServiceStack.OrmLite: migrations, transactions and named connections, schema operations, filtered indexes and constraints, schema diff, generation and SQLite rebuilds, runner and in-progress checks, rebuild preservation scope.
  7. grate: SQL-first workflow, configuration, transactions and dry run, hash-driven anytime scripts, everytime scripts, provider transaction limits, coordination and recovery.

EXPLICIT CHANGES. A LASTING RECORD.

The next version
starts with a change.

Open the manual ↗Contribute on GitHub →