Skip to content

Commit

Permalink
Simplify DB context configuration
Browse files Browse the repository at this point in the history
Removed environment-specific conditions for setting up the database context. All configurations now use a unified method to add the DbContext with detailed error reporting, sensitive data logging, and interceptors.
  • Loading branch information
urumo committed Nov 23, 2024
1 parent c0b864e commit 5d5fc80
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/Argon.Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,9 @@
builder.AddServiceDefaults();
builder.AddRedisOutputCache("cache");
builder.AddRedisClient("cache");

if (builder.Environment.IsManaged())
builder.AddNpgsqlDbContext<ApplicationDbContext>("DefaultConnection", null,
x => x.AddInterceptors([new TimeStampAndSoftDeleteInterceptor()]));
else
builder.Services.AddDbContext<ApplicationDbContext>(x => x
.EnableDetailedErrors()
.EnableSensitiveDataLogging()
.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection"))
.AddInterceptors([new TimeStampAndSoftDeleteInterceptor()]));
builder.Services.AddDbContext<ApplicationDbContext>(x => x
.EnableDetailedErrors().EnableSensitiveDataLogging().UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection"))
.AddInterceptors(new TimeStampAndSoftDeleteInterceptor()));

builder.Services.AddSingleton<IPasswordHashingService, PasswordHashingService>();
builder.Services.AddHttpContextAccessor();
Expand Down

0 comments on commit 5d5fc80

Please sign in to comment.