RelationalDatabaseCreator RelationalDatabaseCreator Class

Definition

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.

public abstract class RelationalDatabaseCreator : IRelationalDatabaseCreator, IDatabaseCreator, IServiceInjectionSite
Public MustInherit Class RelationalDatabaseCreator
    Implements IRelationalDatabaseCreator, IDatabaseCreator, IServiceInjectionSite
Inheritance
System.ObjectSystem.Object
RelationalDatabaseCreatorRelationalDatabaseCreator
Implements

Constructors

RelationalDatabaseCreator(IModel, IRelationalConnection, IMigrationsModelDiffer, IMigrationsSqlGenerator, IMigrationCommandExecutor) RelationalDatabaseCreator(IModel, IRelationalConnection, IMigrationsModelDiffer, IMigrationsSqlGenerator, IMigrationCommandExecutor)

Initializes a new instance of the RelationalDatabaseCreator class.

[Obsolete("Derived classes must be updated to call the new constructor with additional parameters.")]
protected RelationalDatabaseCreator(IModel model, IRelationalConnection connection, IMigrationsModelDiffer modelDiffer, IMigrationsSqlGenerator migrationsSqlGenerator, IMigrationCommandExecutor migrationCommandExecutor)
<Obsolete("Derived classes must be updated to call the new constructor with additional parameters.")>
Protected Sub New(model As IModel, connection As IRelationalConnection, modelDiffer As IMigrationsModelDiffer, migrationsSqlGenerator As IMigrationsSqlGenerator, migrationCommandExecutor As IMigrationCommandExecutor)
Parameters
model
IModel IModel

The IModel for the context this creator is being used with.

RelationalDatabaseCreator(IModel, IRelationalConnection, IMigrationsModelDiffer, IMigrationsSqlGenerator, IMigrationCommandExecutor, IExecutionStrategyFactory) RelationalDatabaseCreator(IModel, IRelationalConnection, IMigrationsModelDiffer, IMigrationsSqlGenerator, IMigrationCommandExecutor, IExecutionStrategyFactory)

Initializes a new instance of the RelationalDatabaseCreator class.

protected RelationalDatabaseCreator(IModel model, IRelationalConnection connection, IMigrationsModelDiffer modelDiffer, IMigrationsSqlGenerator migrationsSqlGenerator, IMigrationCommandExecutor migrationCommandExecutor, IExecutionStrategyFactory executionStrategyFactory)
Protected Sub New(model As IModel, connection As IRelationalConnection, modelDiffer As IMigrationsModelDiffer, migrationsSqlGenerator As IMigrationsSqlGenerator, migrationCommandExecutor As IMigrationCommandExecutor, executionStrategyFactory As IExecutionStrategyFactory)
Parameters
model
IModel IModel

The IModel for the context this creator is being used with.

Properties

Connection Connection

Gets the connection for the database.

protected virtual IRelationalConnection Connection { get; }
Protected Overridable ReadOnly Property Connection As IRelationalConnection

ExecutionStrategyFactory ExecutionStrategyFactory

Gets the IExecutionStrategyFactory to be used.

protected virtual IExecutionStrategyFactory ExecutionStrategyFactory { get; }
Protected Overridable ReadOnly Property ExecutionStrategyFactory As IExecutionStrategyFactory

MigrationCommandExecutor MigrationCommandExecutor

Gets the IMigrationCommandExecutor to be used.

protected virtual IMigrationCommandExecutor MigrationCommandExecutor { get; }
Protected Overridable ReadOnly Property MigrationCommandExecutor As IMigrationCommandExecutor

Model Model

Gets the model for the context this creator is being used with.

protected virtual IModel Model { get; }
Protected Overridable ReadOnly Property Model As IModel
Value
IModel IModel

Methods

Create() Create()

Creates the physical database. Does not attempt to populate it with any schema.

public abstract void Create()
Public MustOverride Sub Create

CreateAsync(CancellationToken) CreateAsync(CancellationToken)

Asynchronously creates the physical database. Does not attempt to populate it with any schema.

public virtual Task CreateAsync(CancellationToken cancellationToken = null)
Public Overridable Function CreateAsync(cancellationToken As CancellationToken = Nothing) As Task
Parameters
cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task System.Threading.Tasks.Task

A task that represents the asynchronous operation.

CreateTables() 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.

public virtual void CreateTables()
Public Overridable Sub CreateTables

CreateTablesAsync(CancellationToken) 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.

public virtual Task CreateTablesAsync(CancellationToken cancellationToken = null)
Public Overridable Function CreateTablesAsync(cancellationToken As CancellationToken = Nothing) As Task
Parameters
cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task System.Threading.Tasks.Task

A task that represents the asynchronous operation.

Delete() Delete()

Deletes the physical database.

public abstract void Delete()
Public MustOverride Sub Delete

DeleteAsync(CancellationToken) DeleteAsync(CancellationToken)

Asynchronously deletes the physical database.

public virtual Task DeleteAsync(CancellationToken cancellationToken = null)
Public Overridable Function DeleteAsync(cancellationToken As CancellationToken = Nothing) As Task
Parameters
cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task System.Threading.Tasks.Task

A task that represents the asynchronous operation.

EnsureCreated() 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.

public virtual bool EnsureCreated()
Public Overridable Function EnsureCreated As Boolean
Returns
System.Boolean System.Boolean

True if the database is created, false if it already existed.

EnsureCreatedAsync(CancellationToken) 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 virtual Task<bool> EnsureCreatedAsync(CancellationToken cancellationToken = null)
Public Overridable Function EnsureCreatedAsync(cancellationToken As CancellationToken = Nothing) As Task(Of Boolean)
Parameters
cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Boolean> System.Threading.Tasks.Task(Of System.Boolean)

A task that represents the asynchronous save operation. The task result contains true if the database is created, false if it already existed.

EnsureDeleted() 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.

public virtual bool EnsureDeleted()
Public Overridable Function EnsureDeleted As Boolean
Returns
System.Boolean System.Boolean

True if the database is deleted, false if it did not exist.

EnsureDeletedAsync(CancellationToken) 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.

public virtual Task<bool> EnsureDeletedAsync(CancellationToken cancellationToken = null)
Public Overridable Function EnsureDeletedAsync(cancellationToken As CancellationToken = Nothing) As Task(Of Boolean)
Parameters
cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Boolean> System.Threading.Tasks.Task(Of System.Boolean)

A task that represents the asynchronous save operation. The task result contains true if the database is deleted, false if it did not exist.

Equals(Object) Equals(Object)

Inherited from System.Object

Equals(Object, Object) Equals(Object, Object)

Inherited from System.Object

Exists() Exists()

Determines whether the physical database exists. No attempt is made to determine if the database contains the schema for the current model.

public abstract bool Exists()
Public MustOverride Function Exists As Boolean
Returns
System.Boolean System.Boolean

True if the database exists; otherwise false.

ExistsAsync(CancellationToken) 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.

public virtual Task<bool> ExistsAsync(CancellationToken cancellationToken = null)
Public Overridable Function ExistsAsync(cancellationToken As CancellationToken = Nothing) As Task(Of Boolean)
Parameters
cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Boolean> System.Threading.Tasks.Task(Of System.Boolean)

A task that represents the asynchronous operation. The task result contains true if the database exists; otherwise false.

GetCreateTablesCommands() GetCreateTablesCommands()

Gets the commands that will create all tables from the model.

protected virtual IReadOnlyList<MigrationCommand> GetCreateTablesCommands()
Protected Overridable Function GetCreateTablesCommands As IReadOnlyList(Of MigrationCommand)
Returns
System.Collections.Generic.IReadOnlyList<MigrationCommand> System.Collections.Generic.IReadOnlyList(Of MigrationCommand)

The generated commands.

GetHashCode() GetHashCode()

Inherited from System.Object

GetType() GetType()

Inherited from System.Object

HasTables() HasTables()

Determines whether the database contains any tables. No attempt is made to determine if tables belong to the current model or not.

protected abstract bool HasTables()
Protected MustOverride Function HasTables As Boolean
Returns
System.Boolean System.Boolean

A value indicating whether any tables are present in the database.

HasTablesAsync(CancellationToken) 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.

protected virtual Task<bool> HasTablesAsync(CancellationToken cancellationToken = null)
Protected Overridable Function HasTablesAsync(cancellationToken As CancellationToken = Nothing) As Task(Of Boolean)
Parameters
cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Boolean> System.Threading.Tasks.Task(Of System.Boolean)

A task that represents the asynchronous operation. The task result contains a value indicating whether any tables are present in the database.

MemberwiseClone() MemberwiseClone()

Inherited from System.Object

ReferenceEquals(Object, Object) ReferenceEquals(Object, Object)

Inherited from System.Object

ToString() ToString()

Inherited from System.Object

Explicit Interface Implementations

IServiceInjectionSite.InjectServices(IServiceProvider) Microsoft.EntityFrameworkCore.Internal.IServiceInjectionSite.InjectServices(IServiceProvider)

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

void IServiceInjectionSite.InjectServices(IServiceProvider serviceProvider)
Sub Microsoft.EntityFrameworkCore.Internal.IServiceInjectionSite.InjectServices(serviceProvider As IServiceProvider) Implements IServiceInjectionSite.InjectServices
Parameters
serviceProvider
System.IServiceProvider System.IServiceProvider