Class MongoMigrationRunner
Discovers the Migration types marked with MigrationAttribute across the supplied assemblies, orders them by timestamp, skips the ones already recorded in the IMigrationHistory, and applies the rest in order through the IMigrationExecutor — recording each as it succeeds. Safe to call on every startup.
public sealed class MongoMigrationRunner : IMigrationRunner
- Inheritance
-
MongoMigrationRunner
- Implements
- Inherited Members
Constructors
MongoMigrationRunner(IMigrationExecutor, IMigrationHistory, IEnumerable<Assembly>, MigrationSource?)
Initializes the runner.
public MongoMigrationRunner(IMigrationExecutor executor, IMigrationHistory history, IEnumerable<Assembly> assemblies, MigrationSource? source = null)
Parameters
executorIMigrationExecutorApplies each migration's declared operations.
historyIMigrationHistoryTracks which migrations have already run.
assembliesIEnumerable<Assembly>The assemblies scanned for migrations.
sourceMigrationSource
Methods
RunAsync(CancellationToken)
Applies every pending migration in timestamp order. Safe to call on every startup — already-applied migrations are skipped.
public Task<int> RunAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenThe cancellation token.