Table of Contents

Class MongoMigrationRunner

Namespace
eQuantic.Core.Data.MongoDb.Migration
Assembly
eQuantic.Core.Data.MongoDb.dll

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

executor IMigrationExecutor

Applies each migration's declared operations.

history IMigrationHistory

Tracks which migrations have already run.

assemblies IEnumerable<Assembly>

The assemblies scanned for migrations.

source MigrationSource

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

cancellationToken CancellationToken

The cancellation token.

Returns

Task<int>

The number of migrations applied by this call.