Skip to content

Commit b4d3892

Browse files
rojiWhatzGames
authored andcommitted
Don't open connection if already open when reloading types (npgsql#3343)
Fixes npgsql#3210
1 parent 899868d commit b4d3892

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/EFCore.PG/Migrations/Internal/NpgsqlMigrator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ public override void Migrate(string? targetMigration)
8080

8181
if (reloadTypes && _connection.DbConnection is NpgsqlConnection npgsqlConnection)
8282
{
83-
npgsqlConnection.Open();
83+
_connection.Open();
8484
try
8585
{
8686
npgsqlConnection.ReloadTypes();
8787
}
8888
catch
8989
{
90-
npgsqlConnection.Close();
90+
_connection.Close();
9191
}
9292
}
9393
}
@@ -123,14 +123,14 @@ public override async Task MigrateAsync(string? targetMigration, CancellationTok
123123

124124
if (reloadTypes && _connection.DbConnection is NpgsqlConnection npgsqlConnection)
125125
{
126-
await npgsqlConnection.OpenAsync(cancellationToken).ConfigureAwait(false);
126+
await _connection.OpenAsync(cancellationToken).ConfigureAwait(false);
127127
try
128128
{
129129
await npgsqlConnection.ReloadTypesAsync().ConfigureAwait(false);
130130
}
131131
catch
132132
{
133-
await npgsqlConnection.CloseAsync().ConfigureAwait(false);
133+
await _connection.CloseAsync().ConfigureAwait(false);
134134
}
135135
}
136136
}

0 commit comments

Comments
 (0)