# Class NpgsqlHistoryRepository

Namespace
  Npgsql.EntityFrameworkCore.PostgreSQL.Migrations.Internal

Assembly
  Npgsql.EntityFrameworkCore.PostgreSQL.dll

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.

    public class NpgsqlHistoryRepository : HistoryRepository, IHistoryRepository

Inheritance
  object
  HistoryRepository
  NpgsqlHistoryRepository

Implements
  IHistoryRepository

Inherited Members
  HistoryRepository.DefaultTableName
  HistoryRepository.GetCreateScript()
  HistoryRepository.Create()
  HistoryRepository.CreateAsync(CancellationToken)
  HistoryRepository.ConfigureTable(EntityTypeBuilder<HistoryRow>)
  HistoryRepository.GetInsertScript(HistoryRow)
  HistoryRepository.GetDeleteScript(string)
  HistoryRepository.Dependencies
  HistoryRepository.SqlGenerationHelper
  HistoryRepository.TableName
  HistoryRepository.TableSchema
  HistoryRepository.MigrationIdColumnName
  HistoryRepository.ProductVersionColumnName
  HistoryRepository.GetAppliedMigrationsSql
  object.Equals(object)
  object.Equals(object, object)
  object.GetHashCode()
  object.GetType()
  object.MemberwiseClone()
  object.ReferenceEquals(object, object)
  object.ToString()

## Constructors

### NpgsqlHistoryRepository(HistoryRepositoryDependencies)

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.

    public NpgsqlHistoryRepository(HistoryRepositoryDependencies dependencies)

#### Parameters

`dependencies` HistoryRepositoryDependencies

## Properties

### ExistsSql

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.

    protected override string ExistsSql { get; }

#### Property Value

string

### 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.

    public override LockReleaseBehavior LockReleaseBehavior { get; }

#### Property Value

LockReleaseBehavior

## Methods

### AcquireDatabaseLock()

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.

    public override IMigrationsDatabaseLock AcquireDatabaseLock()

#### Returns

IMigrationsDatabaseLock

### AcquireDatabaseLockAsync(CancellationToken)

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.

    public override Task<IMigrationsDatabaseLock> AcquireDatabaseLockAsync(CancellationToken cancellationToken = default)

#### Parameters

`cancellationToken` CancellationToken

#### Returns

Task<IMigrationsDatabaseLock>

### Exists()

Always returns true for PostgreSQL - it's difficult to reliably check if the migration history table exists or not (because user may set PG `search_path`, which determines unqualified tables references when creating, selecting). So we instead catch the "table doesn't exist" exceptions instead.

    public override bool Exists()

#### Returns

bool

### ExistsAsync(CancellationToken)

Always returns true for PostgreSQL - it's difficult to reliably check if the migration history table exists or not (because user may set PG `search_path`, which determines unqualified tables references when creating, selecting). So we instead catch the "table doesn't exist" exceptions instead.

    public override Task<bool> ExistsAsync(CancellationToken cancellationToken = default)

#### Parameters

`cancellationToken` CancellationToken

#### Returns

Task<bool>

### GetAppliedMigrations()

Calls the base implementation, but catches "table not found" exceptions; we do this rather than try to detect whether the migration table already exists (see ExistsAsync(CancellationToken) override below), since it's difficult to reliably check if the migration history table exists or not (because user may set PG `search_path`, which determines unqualified tables references when creating, selecting).

    public override IReadOnlyList<HistoryRow> GetAppliedMigrations()

#### Returns

IReadOnlyList<HistoryRow>

### GetAppliedMigrationsAsync(CancellationToken)

Calls the base implementation, but catches "table not found" exceptions; we do this rather than try to detect whether the migration table already exists (see ExistsAsync(CancellationToken) override below), since it's difficult to reliably check if the migration history table exists or not (because user may set PG `search_path`, which determines unqualified tables references when creating, selecting).

    public override Task<IReadOnlyList<HistoryRow>> GetAppliedMigrationsAsync(CancellationToken cancellationToken = default)

#### Parameters

`cancellationToken` CancellationToken

#### Returns

Task<IReadOnlyList<HistoryRow>>

### GetBeginIfExistsScript(string)

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.

    public override string GetBeginIfExistsScript(string migrationId)

#### Parameters

`migrationId` string

#### Returns

string

### GetBeginIfNotExistsScript(string)

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.

    public override string GetBeginIfNotExistsScript(string migrationId)

#### Parameters

`migrationId` string

#### Returns

string

### GetCreateCommands()

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.

    protected override IReadOnlyList<MigrationCommand> GetCreateCommands()

#### Returns

IReadOnlyList<MigrationCommand>

### GetCreateIfNotExistsScript()

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.

    public override string GetCreateIfNotExistsScript()

#### Returns

string

### GetEndIfScript()

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.

    public override string GetEndIfScript()

#### Returns

string

### InterpretExistsResult(object?)

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.

    protected override bool InterpretExistsResult(object? value)

#### Parameters

`value` object

#### Returns

bool