Skip to content

Commit

Permalink
Configure the database-context options only once as suggested in npgs…
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-wacker committed Jan 29, 2025
1 parent 51410b7 commit 4b6d24a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion backend/src/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ApplicationDbContext>(options =>
ConfigureDatabaseContext(options, _environment, _appSettings)
);
// Database context as services are used by `OpenIddict`, see in
// particular `AuthConfiguration`.
services.AddDbContext<ApplicationDbContext>(options =>
ConfigureDatabaseContext(options, _environment, _appSettings),
{},
contextLifetime: ServiceLifetime.Transient,
optionsLifetime: ServiceLifetime.Singleton
);
Expand Down

0 comments on commit 4b6d24a

Please sign in to comment.