RelationalDatabaseCreator RelationalDatabaseCreator Class

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.

Syntax

Declaration

public abstract class RelationalDatabaseCreator : IRelationalDatabaseCreator, IDatabaseCreator, IServiceInjectionSitePublic MustInherit Class RelationalDatabaseCreator
    Implements IRelationalDatabaseCreator, IDatabaseCreator, IServiceInjectionSite

Inheritance Hierarchy

  • System.Object
    System.Object
  • RelationalDatabaseCreator
    RelationalDatabaseCreator

Inherited Members

ToString(),
ToString(),
Equals(Object),
Equals(Object),
Equals(Object, Object),
Equals(Object, Object),
ReferenceEquals(Object, Object),
ReferenceEquals(Object, Object),
GetHashCode(),
GetHashCode(),
GetType(),
GetType(),
MemberwiseClone()
MemberwiseClone()

Constructors summary

Initializes a new instance of the RelationalDatabaseCreator class.

Initializes a new instance of the RelationalDatabaseCreator class.

Properties summary

Gets the connection for the database.

Gets the IExecutionStrategyFactory to be used.

Gets the IMigrationCommandExecutor to be used.

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

Methods summary

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

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

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.

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.

Deletes the physical database.

Asynchronously deletes the physical database.

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.

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.

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.

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.

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

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

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

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

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

Explicit Interface Implementations summary

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.

Constructors

Properties

  • Connection
    Connection

    Gets the connection for the database.

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

    Property Value

  • ExecutionStrategyFactory
    ExecutionStrategyFactory

    Gets the IExecutionStrategyFactory to be used.

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

    Property Value

  • MigrationCommandExecutor
    MigrationCommandExecutor

    Gets the IMigrationCommandExecutor to be used.

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

    Property Value

  • 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

    Property Value

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<TResult><System.Boolean>
      System.Threading.Tasks.Task<TResult>(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<TResult><System.Boolean>
      System.Threading.Tasks.Task<TResult>(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.

  • 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<TResult><System.Boolean>
      System.Threading.Tasks.Task<TResult>(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

  • 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<TResult><System.Boolean>
      System.Threading.Tasks.Task<TResult>(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.

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

Details

Assembly

Microsoft.EntityFrameworkCore.Relational.dll