Table of Contents

Method CreateDatabaseAsync

Namespace
MongoDB.EntityFrameworkCore.Storage
Assembly
MongoDB.EntityFrameworkCore.dll

CreateDatabaseAsync(IModel, CancellationToken)

Create a new database with the name specified in the connection options asynchronously.

Task<bool> CreateDatabaseAsync(IModel model, CancellationToken cancellationToken = default)

Parameters

model IModel

The IModel that informs how the database should be created.

cancellationToken CancellationToken

A CancellationToken that can be used to cancel this asynchronous request.

Returns

Task<bool>

A Task that, when resolved, will be true if the database was created from scratch, false if it already existed.

Remarks

If the database already exists only new collections will be created.