Freigeben über


HistoryRepository Class

Definition

A base class for the repository used to access the '__EFMigrationsHistory' table that tracks metadata about EF Core Migrations such as which migrations have been applied.

public abstract class HistoryRepository : Microsoft.EntityFrameworkCore.Migrations.IHistoryRepository
type HistoryRepository = class
    interface IHistoryRepository
Public MustInherit Class HistoryRepository
Implements IHistoryRepository
Inheritance
HistoryRepository
Implements

Remarks

Database providers must inherit from this class to implement provider-specific functionality.

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 Database migrations for more information and examples.

Constructors

HistoryRepository(HistoryRepositoryDependencies)

Initializes a new instance of this class.

HistoryRepository(IDatabaseCreator, IRawSqlCommandBuilder, IRelationalConnection, IDbContextOptions, IMigrationsModelDiffer, IMigrationsSqlGenerator, IRelationalAnnotationProvider, ISqlGenerationHelper)

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.

Fields

DefaultTableName

The default name for the Migrations history table.

Properties

Dependencies

Relational provider-specific dependencies for this service.

ExistsSql

Overridden by database providers to generate SQL that tests for existence of the history table.

GetAppliedMigrationsSql

Generates SQL to query for the migrations that have been applied.

LockReleaseBehavior

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

MigrationIdColumnName

The name of the column that holds the Migration identifier.

ProductVersionColumnName

The name of the column that contains the Entity Framework product version.

SqlGenerationHelper

A helper class for generation of SQL.

TableName

THe history table name.

TableSchema

The schema that contains the history table, or null if the default schema should be used.

Methods

AcquireDatabaseLock()

Gets an exclusive lock on the database.

AcquireDatabaseLockAsync(CancellationToken)

Gets an exclusive lock on the database.

ConfigureTable(EntityTypeBuilder<HistoryRow>)

Configures the entity type mapped to the history table.

Create()

Creates the history table.

CreateAsync(CancellationToken)

Creates the history table.

Exists()

Checks whether or not the history table exists.

ExistsAsync(CancellationToken)

Checks whether or not the history table exists.

GetAppliedMigrations()

Queries the history table for all migrations that have been applied.

GetAppliedMigrationsAsync(CancellationToken)

Queries the history table for all migrations that have been applied.

GetBeginIfExistsScript(String)

Overridden by database providers to generate a SQL Script that will BEGIN a block of SQL if and only if the migration with the given identifier already exists in the history table.

GetBeginIfNotExistsScript(String)

Overridden by database providers to generate a SQL Script that will BEGIN a block of SQL if and only if the migration with the given identifier does not already exist in the history table.

GetCreateCommands()

Returns the migration commands that will create the history table.

GetCreateIfNotExistsScript()

Overridden by a database provider to generate a SQL script that will create the history table if and only if it does not already exist.

GetCreateScript()

Generates a SQL script that will create the history table.

GetDeleteScript(String)

Generates a SQL script to delete a row from the history table.

GetEndIfScript()

Overridden by database providers to generate a SQL script to END the SQL block.

GetInsertScript(HistoryRow)

Generates a SQL script to insert a row into the history table.

InterpretExistsResult(Object)

Interprets the result of executing ExistsSql.

Explicit Interface Implementations

IHistoryRepository.CreateIfNotExists()
IHistoryRepository.CreateIfNotExistsAsync(CancellationToken)

Applies to