Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/EFCore.PG/Storage/Internal/NpgsqlDatabaseCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,13 @@ public override bool Exists()
{
// When checking whether a database exists, pooling must be off, otherwise we may
// attempt to reuse a pooled connection, which may be broken (this happened in the tests).
var unpooledCsb = new NpgsqlConnectionStringBuilder(_connection.ConnectionString) { Pooling = false };
// If Pooling is off, but Multiplexing is on - NpgsqlConnectionStringBuilder.Validate will throw,
// so we turn off Multiplexing as well.
var unpooledCsb = new NpgsqlConnectionStringBuilder(_connection.ConnectionString)
{
Pooling = false,
Multiplexing = false
};
using var unpooledConn = ((NpgsqlConnection)_connection.DbConnection).CloneWith(unpooledCsb.ToString());
using var _ = new TransactionScope(TransactionScopeOption.Suppress);
unpooledConn.Open();
Expand Down Expand Up @@ -165,7 +171,13 @@ public override async Task<bool> ExistsAsync(CancellationToken cancellationToken
{
// When checking whether a database exists, pooling must be off, otherwise we may
// attempt to reuse a pooled connection, which may be broken (this happened in the tests).
var unpooledCsb = new NpgsqlConnectionStringBuilder(_connection.ConnectionString) { Pooling = false };
// If Pooling is off, but Multiplexing is on - NpgsqlConnectionStringBuilder.Validate will throw,
// so we turn off Multiplexing as well.
var unpooledCsb = new NpgsqlConnectionStringBuilder(_connection.ConnectionString)
{
Pooling = false,
Multiplexing = false
};
using var unpooledConn = ((NpgsqlConnection)_connection.DbConnection).CloneWith(unpooledCsb.ToString());
using var _ = new TransactionScope(TransactionScopeOption.Suppress, TransactionScopeAsyncFlowOption.Enabled);
await unpooledConn.OpenAsync(cancellationToken);
Expand Down