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.

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

ConfigureTable(EntityTypeBuilder<HistoryRow>)

Configures the entity type mapped to 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.

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.

Applies to