Class Migration
Convenience base for IMigration. Supplies Version and Description from the constructor and a DownAsync(IMigrationContext, CancellationToken) that throws (override it to make the migration reversible).
public abstract class Migration : IMigration
- Inheritance
-
Migration
- Implements
- Inherited Members
Remarks
Note that MySQL implicitly commits on DDL. A migration that mixes ALTER with data
changes is therefore not atomic — prefer keeping UpAsync(IMigrationContext, CancellationToken) steps idempotent and
splitting heavy DDL and heavy backfill into separate migrations.
Constructors
Migration(string, int, string)
protected Migration(string appVersion, int order, string description)
Parameters
appVersionstringThe app version this migration ships with (e.g. "1.4.0").
orderintOrder within that version (applied ascending).
descriptionstringHuman-readable description.
Properties
Description
Human-readable description recorded in the __migrations history.
public string Description { get; }
Property Value
Version
The migration's ordered position.
public MigrationVersion Version { get; }
Property Value
Methods
DownAsync(IMigrationContext, CancellationToken)
Reverts the migration. Override to enable rollback; the default Migration base throws NotSupportedException.
public virtual Task DownAsync(IMigrationContext ctx, CancellationToken ct)
Parameters
Returns
UpAsync(IMigrationContext, CancellationToken)
Applies the migration. Runs inside a transaction owned by the runner.
public abstract Task UpAsync(IMigrationContext ctx, CancellationToken ct)