dotnet tool install -g FluentMigrator.DotNet.Cli
You can run the tool with
dotnet fm or
dotnet-fm. Use the latter version if the former doesn't work due to a .NET Core CLI tool bug.
dotnet-fm -+- list -+- migrations = List all available migrations | +- processors = List all available processors +- migrate = Execute migrations | +- up = Execute migrations | +- down = Revert migrations +- rollback = Revert one migration | +- all = Revert all migrations | +- by = Revert <steps> migrations | +- to = Revert migrations down to <version> +- validate --- versions= Validate order of applied migrations
Shows all available processor identifiers to be used by the
--processor command line switch.
Connection related commands
The following commands need a processor id and/or a connection:
- dotnet-fm list migrations
- dotnet-fm migrate
- dotnet-fm rollback
- dotnet-fm validate
The connection string itself to the server and database you want to execute your migrations against.
Indicates that migrations will be generated without consulting a target database. Should only be used when generating an output file.
The kind of database you are migrating against. Available choices can be shown with list processors.
Database processor specific switches, e.g.:
Only output the SQL generated by the migration - do not execute it. Default is false.
Show the SQL statements generated and execution time in the console. Default is false.
The profile to run after executing migrations.
--context <CONTEXT> (obsolete)
Set ApplicationContext to the given string.
Overrides the default database command timeout of 30 seconds.
Output generated SQL to a file. Default is no output. A filename may be specified, otherwise [targetAssemblyName].sql is the default.
The assemblies containing the migrations you want to execute.
The namespace contains the migrations you want to run. Default is all migrations found within the Target Assembly will be run.
Whether migrations in nested namespaces should be included. Used in conjunction with the namespace option.
The specific version to start migrating from. Only used when NoConnection is true. Default is 0.
The directory to load SQL scripts specified by migrations from.
Filters the migrations to be run by tag.
Allows execution of migrations marked as breaking changes.
migrate specific parameters
Overrides the transaction behavior of migrations, so that all migrations to be executed will run in one transaction. Allowed values are:
Reverts all migrations.
rollback by <steps>
Reverts the last
rollback to <version>
Reverts all migrations down to (and excluding)
Applies the found migrations.
The specific version to migrate to.
Applies the found migrations.
The specific version to revert to (exclusive).
Apply all migrations
dotnet fm migrate -p sqlite -c "Data Source=test.db" -a FluentMigrator.Example.Migrations.dll
Apply migrations up to given version
dotnet fm migrate -p sqlite -c "Data Source=test.db" -a FluentMigrator.Example.Migrations.dll up -t 20090906205342