Skip to content

Instantly share code, notes, and snippets.

@explorer14
Created December 25, 2018 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save explorer14/2e4492d6b934af28bb290d504d70f044 to your computer and use it in GitHub Desktop.
Save explorer14/2e4492d6b934af28bb290d504d70f044 to your computer and use it in GitHub Desktop.
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<PeriodContext>(options =>
options.UseSqlServer(
Configuration.GetConnectionString("DbConnectionString"),
builderOptions =>
builderOptions.EnableRetryOnFailure(3)),
ServiceLifetime.Scoped);
services.AddHealthChecks()
.AddCheck("SQL Server",
new DatabaseHealthCheck(
services.BuildServiceProvider()
.GetService<PeriodContext>()));
// rest of the services
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment