Class MongoMigrationExecutor
Applies provider-agnostic MigrationOperations to MongoDB through the driver: it creates
collections and indexes, converts and renames fields across existing documents, runs data updates and
hands the raw database to escape-hatch steps. Typed member selectors are resolved to their stored BSON
element names (honouring [BsonElement] / class maps), so a migration never spells a field as a string.
public sealed class MongoMigrationExecutor : IMigrationExecutor
- Inheritance
-
MongoMigrationExecutor
- Implements
- Inherited Members
Constructors
MongoMigrationExecutor(IMongoDatabase, Func<Type, string>?)
Initializes the executor for a database.
public MongoMigrationExecutor(IMongoDatabase database, Func<Type, string>? collectionName = null)
Parameters
databaseIMongoDatabaseThe target database.
collectionNameFunc<Type, string>Resolves an entity type to its collection name; defaults to the type name, matching the repository's default (
MongoUnitOfWork.CollectionName).
Methods
ApplyAsync(IReadOnlyList<MigrationOperation>, CancellationToken)
Applies the operations, in order.
public Task ApplyAsync(IReadOnlyList<MigrationOperation> operations, CancellationToken cancellationToken = default)
Parameters
operationsIReadOnlyList<MigrationOperation>The declared operations.
cancellationTokenCancellationTokenThe cancellation token.