Skip to content

Commit

Permalink
Add DbContext Health Check
Browse files Browse the repository at this point in the history
  • Loading branch information
DrizzlyOwl committed Jan 6, 2025
1 parent fac3056 commit 0b4a836
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.10" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageReference Include="Microsoft.Identity.Web" Version="3.3.1" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@ public static IServiceCollection AddInfrastructureDependencyGroup(
// Utils
services.AddScoped<IDateTimeProvider, DateTimeProvider>();

// Health check
AddInfrastructureHealthCheck(services);

return services;
}

public static void AddInfrastructureHealthCheck(this IServiceCollection services) {
services.AddHealthChecks()
.AddDbContextCheck<RegionalImprovementForStandardsAndExcellenceContext>("RISE Database");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
// options.Cookie.SecurePolicy = CookieSecurePolicy.Always;
});

builder.Services.AddHealthChecks();

builder.Services.AddScoped(sp => sp.GetService<IHttpContextAccessor>()?.HttpContext?.Session);
// Add services to the container.
builder.Services.AddRazorPages(options =>
Expand Down

0 comments on commit 0b4a836

Please sign in to comment.