Configuration

Select the connection, migration set and history scope first, then set runner options before executing.

Examples use Classic and Fluent tabs. Your choice follows you through the manual.

Connect and select a scope

This host fragment assumes an open ADO.NET connection. The provider scope partitions history and selects explicitly scoped classes. An unscoped migration inherits the provider scope. Scopes do not create separate database objects: two modules can still conflict on a table name.

Host configuration · both styles

Classic

using var billingProvider = ProviderFactory.Create(
    ProviderTypes.SQLite, connection, defaultSchema: null, scope: "billing");
billingProvider.CommandTimeout = 60;
var billing = new Migrator(billingProvider, typeof(CreateUsers).Assembly, false);
billing.SchemaInfoTableName = "BillingSchemaInfo";
billing.Options.Tags.Add("core");
billing.Options.TagMatch = TagMatchMode.All;
billing.Options.TransactionMode = MigrationTransactionMode.WholeSession;
billing.MigrateToLastVersion();

Fluent

using var billingProvider = ProviderFactory.Create(
    ProviderTypes.SQLite, connection, defaultSchema: null, scope: "billing");
billingProvider.CommandTimeout = 60;
var billing = new Migrator(billingProvider, typeof(CreateUsers).Assembly, false);
billing.SchemaInfoTableName = "BillingSchemaInfo";
billing.Options.Tags.Add("core");
billing.Options.TagMatch = TagMatchMode.All;
billing.Options.TransactionMode = MigrationTransactionMode.WholeSession;
billing.MigrateToLastVersion();

Shared host · both styles

Runner options

OptionBehavior
Tags / TagMatchCase-sensitive ordinal tags; match Any or All. No filter selects all versioned migrations.
ProfilesExplicit profile names; selected profiles run after versioned migrations.
TransactionModePerMigration, None or WholeSession. WholeSession supports SQLite, PostgreSQL and SQL Server.
ActivatorOptional delegate for creating migration instances.
Lock / LockTimeoutOptional cross-process lease acquired before reading history; default timeout is 30 seconds.

History and ownership

Set the history table before accessing history or running migrations. Its default name is SchemaInfo; the default scope is default. Give each runner its intended assembly or explicit migration types. Duplicate versions within an effective scope fail discovery.

Load connection strings from application configuration or environment variables. The CLI reads MIGRATOR_CONNECTION by default. Do not store production credentials in migration classes.