Share via


IDatabaseCreator Interface

Definition

Creates and deletes databases for a given database provider.

This interface is typically used by database providers (and other extensions). It is generally not used in application code.

public interface IDatabaseCreator
type IDatabaseCreator = interface
Public Interface IDatabaseCreator
Derived

Remarks

The service lifetime is Scoped. This means that each DbContext instance will use its own instance of this service. The implementation may depend on other services registered with any lifetime. The implementation does not need to be thread-safe.

See Implementation of database providers and extensions for more information and examples.

Methods

CanConnect()

Determines whether or not the database is available and can be connected to.

CanConnectAsync(CancellationToken)

Determines whether or not the database is available and can be connected to.

EnsureCreated()

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.

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.

EnsureDeleted()

Ensures that the database for the context does not exist. If it does not exist, no action is taken. If it does exist then the database is deleted.

Warning: The entire database is deleted an no effort is made to remove just the database objects that are used by the model for this context.

EnsureDeletedAsync(CancellationToken)

Asynchronously ensures that the database for the context does not exist. If it does not exist, no action is taken. If it does exist then the database is deleted.

Warning: The entire database is deleted an no effort is made to remove just the database objects that are used by the model for this context.

Applies to