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 e2ac6ae commit 0c4b4d9
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 @@ -191,14 +191,16 @@ 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 service are used by `Identity` and
// `OpenIddict`, see in particular `AuthConfiguration`,
// `UseUserManagerAttribute` and `UseSignInManagerAttribute`.
services.AddDbContext<ApplicationDbContext>(options =>
ConfigureDatabaseContext(options, _environment, _appSettings),
{},
contextLifetime: ServiceLifetime.Transient,
optionsLifetime: ServiceLifetime.Singleton
);
Expand Down

0 comments on commit 0c4b4d9

Please sign in to comment.