Skip to content

Commit 57167f6

Browse files
committed
Don't open connection if already open when reloading types (#3343)
Fixes #3210 (cherry picked from commit 4078905)
1 parent 8a2dc0c commit 57167f6

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
@@ -78,14 +78,14 @@ public override void Migrate(string? targetMigration = null)
7878

7979
if (reloadTypes && _connection.DbConnection is NpgsqlConnection npgsqlConnection)
8080
{
81-
npgsqlConnection.Open();
81+
_connection.Open();
8282
try
8383
{
8484
npgsqlConnection.ReloadTypes();
8585
}
8686
catch
8787
{
88-
npgsqlConnection.Close();
88+
_connection.Close();
8989
}
9090
}
9191
}
@@ -125,14 +125,14 @@ public override async Task MigrateAsync(
125125

126126
if (reloadTypes && _connection.DbConnection is NpgsqlConnection npgsqlConnection)
127127
{
128-
await npgsqlConnection.OpenAsync(cancellationToken).ConfigureAwait(false);
128+
await _connection.OpenAsync(cancellationToken).ConfigureAwait(false);
129129
try
130130
{
131131
await npgsqlConnection.ReloadTypesAsync().ConfigureAwait(false);
132132
}
133133
catch
134134
{
135-
await npgsqlConnection.CloseAsync().ConfigureAwait(false);
135+
await _connection.CloseAsync().ConfigureAwait(false);
136136
}
137137
}
138138
}

0 commit comments

Comments
 (0)