Command-line tool
List, validate, plan, preview, apply and reverse migrations from a deployment script.
Examples use Classic and Fluent tabs. Your choice follows you through the manual.
Install and connect
Install DotNetProjects.Migrator.Tool as a .NET tool. Set MIGRATOR_CONNECTION in the deployment environment or select another variable with --connection-env. Both Classic and Fluent classes use the same commands. The tool does not print the connection-string value.
Classic
dotnet tool install --global DotNetProjects.Migrator.ToolFluent
dotnet tool install --global DotNetProjects.Migrator.ToolShared commands · both styles
Inspect before applying
Classic
migrator list --assembly MyMigrations.dll --provider SQLite
migrator status --assembly MyMigrations.dll --provider SQLite
migrator validate --assembly MyMigrations.dll --provider SQLite
migrator plan --assembly MyMigrations.dll --provider SQLite --target 10
migrator sql --assembly MyMigrations.dll --provider SQLite --output migration.sqlFluent
migrator list --assembly MyMigrations.dll --provider SQLite
migrator status --assembly MyMigrations.dll --provider SQLite
migrator validate --assembly MyMigrations.dll --provider SQLite
migrator plan --assembly MyMigrations.dll --provider SQLite --target 10
migrator sql --assembly MyMigrations.dll --provider SQLite --output migration.sqlShared commands · both styles
Validate checks version planning, not arbitrary migration-body behavior. Plan lists version steps without running bodies. SQL generation renders a supported operation subset; it does not produce an idempotent history-managed bundle.
Apply and roll back
Classic
migrator migrate --assembly MyMigrations.dll --provider SQLite --scope billing --transaction WholeSession
migrator rollback --assembly MyMigrations.dll --provider SQLite --scope billing --target 0Fluent
migrator migrate --assembly MyMigrations.dll --provider SQLite --scope billing --transaction WholeSession
migrator rollback --assembly MyMigrations.dll --provider SQLite --scope billing --target 0Shared commands · both styles
Rollback requires an explicit lower target and rejects any plan containing upward steps. Target checks run after taking the configured lock and refreshing history. Tags, profiles and provider choice must match the intended deployment.
Options and exit codes
| Option | Purpose |
|---|---|
| --tags a,b / --tag-match Any|All | Filter versioned migrations. |
| --profiles a,b | Select named profiles. |
| --schema / --scope | Provider schema and migration history scope. |
| --timeout SECONDS | Database command timeout. |
| --lock / --lock-timeout SECONDS | Native migration lock on supported providers. |
| --offline | SQL generation assuming empty history; profiles/maintenance rejected. |
Exit codes: 0 success; 1 load/execution failure; 2 invalid arguments; 3 unsupported provider/operation; 4 lock timeout. SQL output can contain data authored in migrations. The packaged drivers cover SQLite, SQL Server, PostgreSQL, MySQL/MariaDB, Oracle and Firebird; use a custom host for other library providers.