Automatic reversal
Fluent operations can describe a supported reverse sequence; Classic migrations author it directly.
Examples use Classic and Fluent tabs. Your choice follows you through the manual.
Creation and its reverse
AutoReversingMigration derives reverse operations in reverse order and validates reversal support before its first change. The Classic equivalent makes the Down operation explicit. Both examples below create the same table and remove it on downgrade.
Classic
using System;
+Automatic reversal
Fluent operations can describe a supported reverse sequence; Classic migrations author it directly.
Examples use Classic and Fluent tabs. Your choice follows you through the manual.
Creation and its reverse
AutoReversingMigration derives reverse operations in reverse order and validates reversal support before its first change. The Classic equivalent makes the Down operation explicit. Both examples below create the same table and remove it on downgrade.
Classic
using System;
using System.Data;
using DotNetProjects.Migrator;
using DotNetProjects.Migrator.Framework;
@@ -17,9 +17,9 @@
{
public override void Up() => Database.AddTable("Notes", new Column("Text", DbType.String, 500));
public override void Down() => Database.RemoveTable("Notes");
-}Fluent
using System;
+}Fluent
using System;
using System.Data;
using DotNetProjects.Migrator;
using DotNetProjects.Migrator.Framework;
diff --git a/docs/guide/cli.html b/docs/guide/cli.html
index fbe17d14..0e8de4d9 100644
--- a/docs/guide/cli.html
+++ b/docs/guide/cli.html
@@ -5,26 +5,26 @@
Migrator.NET
-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
+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 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 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.