Skip to content

Commit 51fad9c

Browse files
authored
Stop include data source connection string in service provider hashcode (#3501)
Fixes #3498
1 parent 86e9948 commit 51fad9c

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/EFCore.PG/Infrastructure/Internal/NpgsqlOptionsExtension.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -486,11 +486,6 @@ public override int GetServiceProviderHashCode()
486486
hashCode.Add(userRangeDefinition);
487487
}
488488

489-
if (Extension.DataSource is not null)
490-
{
491-
hashCode.Add(Extension.DataSource.ConnectionString);
492-
}
493-
494489
hashCode.Add(Extension.AdminDatabase);
495490
hashCode.Add(Extension.PostgresVersion);
496491
hashCode.Add(Extension.UseRedshift);

test/EFCore.PG.Tests/NpgsqlDbContextOptionsExtensionsTest.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,5 +116,19 @@ public void Service_collection_extension_method_can_configure_npgsql_options(boo
116116
}
117117
}
118118

119+
[ConditionalFact]
120+
public void Varying_data_source_connection_strings_do_not_cause_multiple_service_providers()
121+
{
122+
for (var i = 0; i < 21; i++)
123+
{
124+
var optionsBuilder = new DbContextOptionsBuilder<DbContext>();
125+
var dataSource = NpgsqlDataSource.Create($"Host=localhost;Database={i};Include Error Detail=true;Username=admin;Password=admin");
126+
optionsBuilder.UseNpgsql(dataSource);
127+
128+
using var context = new ApplicationDbContext(optionsBuilder.Options);
129+
_ = context.Model;
130+
}
131+
}
132+
119133
private class ApplicationDbContext(DbContextOptions options) : DbContext(options);
120134
}

0 commit comments

Comments
 (0)