RelationalDatabaseFacadeExtensions RelationalDatabaseFacadeExtensions Class

Syntax

Declaration

public static class RelationalDatabaseFacadeExtensionsPublic Module RelationalDatabaseFacadeExtensions

Inheritance Hierarchy

  • System.Object
    System.Object
  • RelationalDatabaseFacadeExtensions
    RelationalDatabaseFacadeExtensions

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

Methods summary

Gets all migrations that have been applied to the target database.

Asynchronously gets all migrations that have been applied to the target database.

Gets all the migrations that are defined in the configured migrations assembly.

Gets all migrations that are defined in the assembly but haven't been applied to the target database.

Asynchronously gets all migrations that are defined in the assembly but haven't been applied to the target database.

Applies any pending migrations for the context to the database. Will create the database if it does not already exist.

Note that this API is mutually exclusive with DbContext.Database.EnsureCreated(). EnsureCreated does not use migrations to create the database and therefore the database that is created cannot be later updated using migrations.

Asynchronously applies any pending migrations for the context to the database. Will create the database if it does not already exist.

Note that this API is mutually exclusive with DbContext.Database.EnsureCreated(). EnsureCreated does not use migrations to create the database and therefore the database that is created cannot be later updated using migrations.

Methods

  • BeginTransaction(DatabaseFacade, IsolationLevel)
    BeginTransaction(DatabaseFacade, IsolationLevel)
    public static IDbContextTransaction BeginTransaction(this DatabaseFacade databaseFacade, IsolationLevel isolationLevel)<ExtensionAttribute>
    Public Shared Function BeginTransaction(databaseFacade As DatabaseFacade, isolationLevel As IsolationLevel) As IDbContextTransaction

    Parameters

    Returns

  • BeginTransactionAsync(DatabaseFacade, IsolationLevel, CancellationToken)
    BeginTransactionAsync(DatabaseFacade, IsolationLevel, CancellationToken)
    public static Task<IDbContextTransaction> BeginTransactionAsync(this DatabaseFacade databaseFacade, IsolationLevel isolationLevel, CancellationToken cancellationToken = null)<ExtensionAttribute>
    Public Shared Function BeginTransactionAsync(databaseFacade As DatabaseFacade, isolationLevel As IsolationLevel, cancellationToken As CancellationToken = Nothing) As Task(Of IDbContextTransaction)

    Parameters

    • databaseFacade
    • isolationLevel
      System.Data.IsolationLevel
      System.Data.IsolationLevel
    • cancellationToken
      System.Threading.CancellationToken
      System.Threading.CancellationToken

    Returns

  • CloseConnection(DatabaseFacade)
    CloseConnection(DatabaseFacade)
    public static void CloseConnection(this DatabaseFacade databaseFacade)<ExtensionAttribute>
    Public Shared Sub CloseConnection(databaseFacade As DatabaseFacade)

    Parameters

  • ExecuteSqlCommand(DatabaseFacade, String, Object[])
    ExecuteSqlCommand(DatabaseFacade, String, Object())
    public static int ExecuteSqlCommand(this DatabaseFacade databaseFacade, string sql, params object[] parameters)<ExtensionAttribute>
    Public Shared Function ExecuteSqlCommand(databaseFacade As DatabaseFacade, sql As String, ParamArray parameters As Object()) As Integer

    Parameters

    Returns

    • System.Int32
      System.Int32
  • ExecuteSqlCommandAsync(DatabaseFacade, String, CancellationToken, Object[])
    ExecuteSqlCommandAsync(DatabaseFacade, String, CancellationToken, Object())
    public static Task<int> ExecuteSqlCommandAsync(this DatabaseFacade databaseFacade, string sql, CancellationToken cancellationToken = null, params object[] parameters)<ExtensionAttribute>
    Public Shared Function ExecuteSqlCommandAsync(databaseFacade As DatabaseFacade, sql As String, cancellationToken As CancellationToken = Nothing, ParamArray parameters As Object()) As Task(Of Integer)

    Parameters

    • databaseFacade
    • sql
      System.String
      System.String
    • cancellationToken
      System.Threading.CancellationToken
      System.Threading.CancellationToken
    • parameters
      System.Object[]
      System.Object()

    Returns

    • System.Threading.Tasks.Task<TResult><System.Int32>
      System.Threading.Tasks.Task<TResult>(Of System.Int32)
  • GetAppliedMigrations(DatabaseFacade)
    GetAppliedMigrations(DatabaseFacade)

    Gets all migrations that have been applied to the target database.

    public static IEnumerable<string> GetAppliedMigrations(this DatabaseFacade databaseFacade)<ExtensionAttribute>
    Public Shared Function GetAppliedMigrations(databaseFacade As DatabaseFacade) As IEnumerable(Of String)

    Parameters

    Returns

    • System.Collections.Generic.IEnumerable<T><System.String>
      System.Collections.Generic.IEnumerable<T>(Of System.String)

      The list of migrations.

  • GetAppliedMigrationsAsync(DatabaseFacade, CancellationToken)
    GetAppliedMigrationsAsync(DatabaseFacade, CancellationToken)

    Asynchronously gets all migrations that have been applied to the target database.

    public static Task<IEnumerable<string>> GetAppliedMigrationsAsync(this DatabaseFacade databaseFacade, CancellationToken cancellationToken = null)<ExtensionAttribute>
    Public Shared Function GetAppliedMigrationsAsync(databaseFacade As DatabaseFacade, cancellationToken As CancellationToken = Nothing) As Task(Of IEnumerable(Of String))

    Parameters

    • databaseFacade

      The DatabaseFacade for the context.

    • 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.Collections.Generic.IEnumerable<T><System.String>>
      System.Threading.Tasks.Task<TResult>(Of System.Collections.Generic.IEnumerable<T>(Of System.String))

      A task that represents the asynchronous operation.

  • GetCommandTimeout(DatabaseFacade)
    GetCommandTimeout(DatabaseFacade)
    public static int ? GetCommandTimeout(this DatabaseFacade databaseFacade)<ExtensionAttribute>
    Public Shared Function GetCommandTimeout(databaseFacade As DatabaseFacade) As Integer?

    Parameters

    Returns

    • System.Nullable<T><System.Int32>
      System.Nullable<T>(Of System.Int32)
  • GetDbConnection(DatabaseFacade)
    GetDbConnection(DatabaseFacade)
    public static DbConnection GetDbConnection(this DatabaseFacade databaseFacade)<ExtensionAttribute>
    Public Shared Function GetDbConnection(databaseFacade As DatabaseFacade) As DbConnection

    Parameters

    Returns

    • System.Data.Common.DbConnection
      System.Data.Common.DbConnection
  • GetMigrations(DatabaseFacade)
    GetMigrations(DatabaseFacade)

    Gets all the migrations that are defined in the configured migrations assembly.

    public static IEnumerable<string> GetMigrations(this DatabaseFacade databaseFacade)<ExtensionAttribute>
    Public Shared Function GetMigrations(databaseFacade As DatabaseFacade) As IEnumerable(Of String)

    Parameters

    Returns

    • System.Collections.Generic.IEnumerable<T><System.String>
      System.Collections.Generic.IEnumerable<T>(Of System.String)

      The list of migrations.

  • GetPendingMigrations(DatabaseFacade)
    GetPendingMigrations(DatabaseFacade)

    Gets all migrations that are defined in the assembly but haven't been applied to the target database.

    public static IEnumerable<string> GetPendingMigrations(this DatabaseFacade databaseFacade)<ExtensionAttribute>
    Public Shared Function GetPendingMigrations(databaseFacade As DatabaseFacade) As IEnumerable(Of String)

    Parameters

    Returns

    • System.Collections.Generic.IEnumerable<T><System.String>
      System.Collections.Generic.IEnumerable<T>(Of System.String)

      The list of migrations.

  • GetPendingMigrationsAsync(DatabaseFacade, CancellationToken)
    GetPendingMigrationsAsync(DatabaseFacade, CancellationToken)

    Asynchronously gets all migrations that are defined in the assembly but haven't been applied to the target database.

    public static Task<IEnumerable<string>> GetPendingMigrationsAsync(this DatabaseFacade databaseFacade, CancellationToken cancellationToken = null)<ExtensionAttribute>
    Public Shared Function GetPendingMigrationsAsync(databaseFacade As DatabaseFacade, cancellationToken As CancellationToken = Nothing) As Task(Of IEnumerable(Of String))

    Parameters

    • databaseFacade

      The DatabaseFacade for the context.

    • 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.Collections.Generic.IEnumerable<T><System.String>>
      System.Threading.Tasks.Task<TResult>(Of System.Collections.Generic.IEnumerable<T>(Of System.String))

      A task that represents the asynchronous operation.

  • Migrate(DatabaseFacade)
    Migrate(DatabaseFacade)

    Applies any pending migrations for the context to the database. Will create the database if it does not already exist.

    Note that this API is mutually exclusive with DbContext.Database.EnsureCreated(). EnsureCreated does not use migrations to create the database and therefore the database that is created cannot be later updated using migrations.

    public static void Migrate(this DatabaseFacade databaseFacade)<ExtensionAttribute>
    Public Shared Sub Migrate(databaseFacade As DatabaseFacade)

    Parameters

  • MigrateAsync(DatabaseFacade, CancellationToken)
    MigrateAsync(DatabaseFacade, CancellationToken)

    Asynchronously applies any pending migrations for the context to the database. Will create the database if it does not already exist.

    Note that this API is mutually exclusive with DbContext.Database.EnsureCreated(). EnsureCreated does not use migrations to create the database and therefore the database that is created cannot be later updated using migrations.

    public static Task MigrateAsync(this DatabaseFacade databaseFacade, CancellationToken cancellationToken = null)<ExtensionAttribute>
    Public Shared Function MigrateAsync(databaseFacade As DatabaseFacade, cancellationToken As CancellationToken = Nothing) As Task

    Parameters

    • databaseFacade

      The DatabaseFacade for the context.

    • 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 migration operation.

  • OpenConnection(DatabaseFacade)
    OpenConnection(DatabaseFacade)
    public static void OpenConnection(this DatabaseFacade databaseFacade)<ExtensionAttribute>
    Public Shared Sub OpenConnection(databaseFacade As DatabaseFacade)

    Parameters

  • OpenConnectionAsync(DatabaseFacade, CancellationToken)
    OpenConnectionAsync(DatabaseFacade, CancellationToken)
    public static Task OpenConnectionAsync(this DatabaseFacade databaseFacade, CancellationToken cancellationToken = null)<ExtensionAttribute>
    Public Shared Function OpenConnectionAsync(databaseFacade As DatabaseFacade, cancellationToken As CancellationToken = Nothing) As Task

    Parameters

    Returns

    • System.Threading.Tasks.Task
      System.Threading.Tasks.Task
  • SetCommandTimeout(DatabaseFacade, Nullable<Int32>)
    SetCommandTimeout(DatabaseFacade, Nullable(Of Int32))
    public static void SetCommandTimeout(this DatabaseFacade databaseFacade, int ? timeout)<ExtensionAttribute>
    Public Shared Sub SetCommandTimeout(databaseFacade As DatabaseFacade, timeout As Integer?)

    Parameters

  • UseTransaction(DatabaseFacade, DbTransaction)
    UseTransaction(DatabaseFacade, DbTransaction)
    public static IDbContextTransaction UseTransaction(this DatabaseFacade databaseFacade, DbTransaction transaction)<ExtensionAttribute>
    Public Shared Function UseTransaction(databaseFacade As DatabaseFacade, transaction As DbTransaction) As IDbContextTransaction

    Parameters

    Returns

Details

Assembly

Microsoft.EntityFrameworkCore.Relational.dll