Method EnsureCreatedAsync
- Namespace
- MongoDB.EntityFrameworkCore
- Assembly
- MongoDB.EntityFrameworkCore.dll
EnsureCreatedAsync(DatabaseFacade, MongoDatabaseCreationOptions, CancellationToken)
Asynchronously ensures that the database for the context exists. If it exists, no action is taken. If it does not exist then the MongoDB database is created using the MongoDatabaseCreationOptions to determine what additional actions to take.
public static Task<bool> EnsureCreatedAsync(this DatabaseFacade databaseFacade, MongoDatabaseCreationOptions options, CancellationToken cancellationToken = default)
Parameters
databaseFacadeDatabaseFacadeThe DatabaseFacade from the EF Core DbContext.
optionsMongoDatabaseCreationOptionsAn MongoDatabaseCreationOptions object specifying additional actions to be taken.
cancellationTokenCancellationTokenA CancellationToken to observe while waiting for the task to complete.