diff --git a/src/EFCore.PG/Migrations/Internal/NpgsqlMigrator.cs b/src/EFCore.PG/Migrations/Internal/NpgsqlMigrator.cs index 0d32f58c0..8691f9322 100644 --- a/src/EFCore.PG/Migrations/Internal/NpgsqlMigrator.cs +++ b/src/EFCore.PG/Migrations/Internal/NpgsqlMigrator.cs @@ -80,14 +80,14 @@ public override void Migrate(string? targetMigration) if (reloadTypes && _connection.DbConnection is NpgsqlConnection npgsqlConnection) { - npgsqlConnection.Open(); + _connection.Open(); try { npgsqlConnection.ReloadTypes(); } catch { - npgsqlConnection.Close(); + _connection.Close(); } } } @@ -123,14 +123,14 @@ public override async Task MigrateAsync(string? targetMigration, CancellationTok if (reloadTypes && _connection.DbConnection is NpgsqlConnection npgsqlConnection) { - await npgsqlConnection.OpenAsync(cancellationToken).ConfigureAwait(false); + await _connection.OpenAsync(cancellationToken).ConfigureAwait(false); try { await npgsqlConnection.ReloadTypesAsync().ConfigureAwait(false); } catch { - await npgsqlConnection.CloseAsync().ConfigureAwait(false); + await _connection.CloseAsync().ConfigureAwait(false); } } }