From 4b6d24acf4cde5b89dcb973e49aa7efe1d6b1630 Mon Sep 17 00:00:00 2001 From: Simon Wacker Date: Wed, 29 Jan 2025 17:34:13 +0100 Subject: [PATCH] Configure the database-context options only once as suggested in https://github.com/npgsql/efcore.pg/issues/3375#issuecomment-2509746639 --- backend/src/Startup.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/src/Startup.cs b/backend/src/Startup.cs index 4492d80..4d83d2b 100644 --- a/backend/src/Startup.cs +++ b/backend/src/Startup.cs @@ -187,13 +187,15 @@ AppSettings appSettings private void ConfigureDatabaseServices(IServiceCollection services) { + // Configure the database-context options only once as suggested in + // https://github.com/npgsql/efcore.pg/issues/3375#issuecomment-2509746639 services.AddPooledDbContextFactory(options => ConfigureDatabaseContext(options, _environment, _appSettings) ); // Database context as services are used by `OpenIddict`, see in // particular `AuthConfiguration`. services.AddDbContext(options => - ConfigureDatabaseContext(options, _environment, _appSettings), + {}, contextLifetime: ServiceLifetime.Transient, optionsLifetime: ServiceLifetime.Singleton );