Method EnsureCreatedAsync
- Namespace
- MongoDB.EntityFrameworkCore.Storage
- Assembly
- MongoDB.EntityFrameworkCore.dll
EnsureCreatedAsync(CancellationToken)
Asynchronously ensures that the database for the context exists. If it exists, no action is taken. If it does not exist then the database and all its schema are created. If the database exists, then no effort is made to ensure it is compatible with the model for this context.
public Task<bool> EnsureCreatedAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
- Task<bool>
A task that represents the asynchronous save operation. The task result contains true if the database is created, false if it already existed.
Exceptions
- OperationCanceledException
If the CancellationToken is canceled.