@@ -135,10 +135,6 @@ public class TbmDbContext<TModelCacheKeyFactory>(ILogger<TbmDbContext<TModelCach
135
135
: TbmDbContext ( logger )
136
136
where TModelCacheKeyFactory : class , IModelCacheKeyFactory
137
137
{
138
- [ SuppressMessage ( "ReSharper" , "StaticMemberInGenericType" ) ]
139
- [ SuppressMessage ( "Major Code Smell" , "S2743:Static fields should not be used in generic types" ) ]
140
- private static Lazy < NpgsqlDataSource > ? _dataSourceSingleton ;
141
-
142
138
// ReSharper disable once UnusedAutoPropertyAccessor.Global
143
139
public required IConfiguration Config { private get ; init ; }
144
140
public DbSet < ImageInReply > ImageInReplies => Set < ImageInReply > ( ) ;
@@ -152,7 +148,7 @@ protected static void OnModelCreatingWithFid(ModelBuilder b, uint fid) =>
152
148
[ SuppressMessage ( "Style" , "IDE0058:Expression value is never used" ) ]
153
149
protected override void OnConfiguring ( DbContextOptionsBuilder options )
154
150
{
155
- options . UseNpgsql ( GetNpgsqlDataSource ( Config . GetConnectionString ( "Main" ) ) . Value , OnConfiguringNpgsql )
151
+ options . UseNpgsql ( Config . GetConnectionString ( "Main" ) , OnConfiguringNpgsql )
156
152
. ReplaceService < IModelCacheKeyFactory , TModelCacheKeyFactory > ( )
157
153
. ReplaceService < IRelationalTransactionFactory , NoSavePointTransactionFactory > ( )
158
154
. AddInterceptors ( UseCurrentXactIdAsConcurrencyTokenCommandInterceptor . Instance )
@@ -180,14 +176,4 @@ protected override void OnModelCreating(ModelBuilder b)
180
176
}
181
177
182
178
protected virtual void OnConfiguringNpgsql ( NpgsqlDbContextOptionsBuilder builder ) { }
183
- protected virtual void OnBuildingNpgsqlDataSource ( NpgsqlDataSourceBuilder builder ) { }
184
-
185
- [ SuppressMessage ( "Critical Code Smell" , "S2696:Instance members should not write to \" static\" fields" ) ]
186
- private Lazy < NpgsqlDataSource > GetNpgsqlDataSource ( string ? connectionString ) =>
187
- _dataSourceSingleton ??= new ( ( ) =>
188
- {
189
- var dataSourceBuilder = new NpgsqlDataSourceBuilder ( connectionString ) ;
190
- OnBuildingNpgsqlDataSource ( dataSourceBuilder ) ;
191
- return dataSourceBuilder . Build ( ) ;
192
- } ) ;
193
179
}
0 commit comments