DOTNETPROJECTS / THE MIGRATION MANUAL
Know what changes.
Know how it runs.
From your first table to deployment locks and SQLite reconstruction. Practical guides with a Classic and Fluent example for every authoring task.
Start with a working example ↗01Introduction
- Your first migration ↗
Create a SQLite database, apply a versioned change, and write its reverse. Choose either C# style; the runner is the same.
- Installation ↗
The core library, database driver, optional DI integration and CLI each have a distinct job.
- Configuration ↗
Select the connection, migration set and history scope first, then set runner options before executing.
- Frequently asked questions ↗
Decisions to make before adopting the library or moving an existing migration project.
02Operations
- Creating tables ↗
Describe a complete table: columns first, with explicit named keys and constraints.
- Altering tables ↗
Rename objects and evolve populated tables while preserving the schema details you still need.
- Columns and data types ↗
Type, size, precision, nullability, defaults, identity and collation are explicit column attributes.
- Data operations ↗
Insert, update and delete using explicit column/value arrays. Keep predicates separate from changed values.
- Schema inspection ↗
Read the connected database before deciding what to change. Metadata is different from a model snapshot.
- Execute SQL and scripts ↗
Use schema operations where they fit, and keep database-specific SQL explicit.
- Commands and callbacks ↗
Use the active provider connection when a migration needs driver-level work.
03Schema basics
- Indexes ↗
An index is a separate schema object, even when it enforces uniqueness.
- Keys and constraints ↗
Declare table invariants independently of column attributes.
- Foreign keys ↗
Define ordered child/parent columns and independent actions for update and delete.
- Defaults and collations ↗
Distinguish values from SQL expressions, and comparison intent from a provider's installed collation name.
04Migration runners
- Choose a runner ↗
Use the same migration assembly in a dedicated host, a DI scope or the command-line tool.
- Command-line tool ↗
List, validate, plan, preview, apply and reverse migrations from a deployment script.
- Dependency injection and logging ↗
Resolve the runner and migration dependencies inside one service scope.
- Planning and SQL preview ↗
A version plan answers what runs. SQL preview shows the supported operation SQL.
- Transactions and locks ↗
Transaction rollback and cross-process coordination solve different problems.
05Migration types
- Versioning and scoped history ↗
Number changes, keep applied source immutable and give independent modules explicit histories.
- Tags ↗
Select a subset of versioned migrations using explicit ordinal names.
- Profiles ↗
Run explicitly selected work after versioned migrations without recording a version.
- Maintenance migrations ↗
Place ordered work at the runner's lifecycle stages.
- Automatic reversal ↗
Fluent operations can describe a supported reverse sequence; Classic migrations author it directly.
06Database providers
- Provider overview ↗
One authoring contract, explicit database behavior. Choose the driver and provider together.
- SQLite ↗
Change existing tables from the live schema, without maintaining an ORM model.
- SQL Server ↗
Explicit keys, provider-specific indexes, transactional DDL and application locks.
- PostgreSQL ↗
Native intervals, schema-aware metadata, transactional DDL and advisory locks.
- MySQL and MariaDB ↗
Related providers with explicit engine, collation and DDL transaction differences.
- Oracle ↗
Preserve explicit constraints and be deliberate about identity, sequences and implicit DDL commits.
- HANA and additional providers ↗
Use the live-engine matrix to qualify operations beyond the common database families.
07Advanced topics
- Conditional logic ↗
Choose between inspecting the live schema and declaring a provider-specific operation.
- Custom extensions ↗
Reuse schema conventions without hiding provider behavior or changing the migration contract.
- Testing and deployment ↗
Verify stored data, preserved schema and repeat execution on the actual target engine.
- Upgrading existing migrations ↗
Update source definitions while preserving the history your databases already contain.
08Reference
- Classic / Fluent API map ↗
A practical index of the two authoring surfaces and their shared provider contracts.
- Contributing ↗
Make a provider change reproducible, then verify its observable behavior.