Skip to content

Commit

Permalink
Don't open connection if already open when reloading types (#3343)
Browse files Browse the repository at this point in the history
Fixes #3210
  • Loading branch information
roji authored Oct 31, 2024
1 parent 592588d commit 4078905
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/EFCore.PG/Migrations/Internal/NpgsqlMigrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
Expand Down Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit 4078905

Please sign in to comment.