Components for performing health checks using EntityFrameworkCore. This package was built from the source code at https://github.com/dotnet/dotnet/tree/87bc0b04e21d786669142109a5128c95618b75ed
$ dotnet add package Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCoreMicrosoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore provides components for performing health checks using Entity Framework Core (EF Core).
To use Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore, follow these steps:
dotnet add package Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore
To add a health check for an EF Core DbContext, use the AddDbContextCheck extension method to configure it with your app's service provider. Here's an example:
builder.Services.AddDbContext<SampleDbContext>(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));
builder.Services.AddHealthChecks()
.AddDbContextCheck<SampleDbContext>();
For additional documentation and examples, refer to the official documentation on using the Entity Framework Core DbContext probe.
Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore is released as open-source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.