Interface IRelationalDatabaseCreator
- Namespace
- Microsoft.EntityFrameworkCore.Storage
- Assembly
- Microsoft.EntityFrameworkCore.Relational.dll
Performs database/schema creation, and other related operations.
This type is typically used by database providers (and other extensions). It is generally not used in application code.
The service lifetime is Scoped. This means that each Microsoft.EntityFrameworkCore.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.
public interface IRelationalDatabaseCreator : IDatabaseCreator
Methods
Create()
Creates the physical database. Does not attempt to populate it with any schema.
void Create()
CreateAsync(CancellationToken)
Asynchronously creates the physical database. Does not attempt to populate it with any schema.
Task CreateAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
- Task
A task that represents the asynchronous operation.
CreateTables()
Creates all tables for the current model in the database. No attempt is made to incrementally update the schema. It is assumed that none of the tables exist in the database.
void CreateTables()
CreateTablesAsync(CancellationToken)
Asynchronously creates all tables for the current model in the database. No attempt is made to incrementally update the schema. It is assumed that none of the tables exist in the database.
Task CreateTablesAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
- Task
A task that represents the asynchronous operation.
Delete()
Deletes the physical database.
void Delete()
DeleteAsync(CancellationToken)
Asynchronously deletes the physical database.
Task DeleteAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
- Task
A task that represents the asynchronous operation.
Exists()
Determines whether the physical database exists. No attempt is made to determine if the database contains the schema for the current model.
bool Exists()
Returns
ExistsAsync(CancellationToken)
Asynchronously determines whether the physical database exists. No attempt is made to determine if the database contains the schema for the current model.
Task<bool> ExistsAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
- Task<bool>
A task that represents the asynchronous operation. The task result contains true if the database exists; otherwise false.
GenerateCreateScript()
Generates a script to create all tables for the current model.
string GenerateCreateScript()
Returns
- string
A SQL script.
HasTables()
Determines whether the database contains any tables. No attempt is made to determine if tables belong to the current model or not.
bool HasTables()
Returns
- bool
A value indicating whether any tables are present in the database.
HasTablesAsync(CancellationToken)
Asynchronously determines whether the database contains any tables. No attempt is made to determine if tables belong to the current model or not.
Task<bool> HasTablesAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenA CancellationToken to observe while waiting for the task to complete.