CSharpEssentials.EntityFrameworkCore.HealthChecks 9.0.0

dotnet add package CSharpEssentials.EntityFrameworkCore.HealthChecks --version 9.0.0
                    
NuGet\Install-Package CSharpEssentials.EntityFrameworkCore.HealthChecks -Version 9.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CSharpEssentials.EntityFrameworkCore.HealthChecks" Version="9.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CSharpEssentials.EntityFrameworkCore.HealthChecks" Version="9.0.0" />
                    
Directory.Packages.props
<PackageReference Include="CSharpEssentials.EntityFrameworkCore.HealthChecks" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CSharpEssentials.EntityFrameworkCore.HealthChecks --version 9.0.0
                    
#r "nuget: CSharpEssentials.EntityFrameworkCore.HealthChecks, 9.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CSharpEssentials.EntityFrameworkCore.HealthChecks@9.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CSharpEssentials.EntityFrameworkCore.HealthChecks&version=9.0.0
                    
Install as a Cake Addin
#tool nuget:?package=CSharpEssentials.EntityFrameworkCore.HealthChecks&version=9.0.0
                    
Install as a Cake Tool

CSharpEssentials.EntityFrameworkCore.HealthChecks

A readiness health check for EF Core. It reports Unhealthy while a DbContext has migrations that are not applied, so /health/ready keeps traffic away from an instance whose database schema is behind its code.

It is a separate package because it depends on Microsoft.Extensions.Diagnostics.HealthChecks, which CSharpEssentials.EntityFrameworkCore does not.

Install

dotnet add package CSharpEssentials.EntityFrameworkCore.HealthChecks

Targets net10.0, net9.0 and net8.0, each on the EF Core major of CSharpEssentials.EntityFrameworkCore.

Usage

using CSharpEssentials.EntityFrameworkCore.HealthChecks;

builder.Services.AddDbContext<AppDbContext>(options => options.UseNpgsql(connectionString));
builder.Services.AddHealthChecks()
    .AddMigrationsCheck<AppDbContext>();   // name "AppDbContext-migrations", tag "ready"

app.MapHealthChecks("/health/ready", new HealthCheckOptions
{
    Predicate = check => check.Tags.Contains(MigrationsHealthCheckBuilderExtensions.ReadyTag),
});
Member What it does
AddMigrationsCheck<TContext>(name?, failureStatus?, tags?, timeout?) Adds the check. name defaults to "{TContext}-migrations", tags to ["ready"], failureStatus to Unhealthy
DbContextMigrationsHealthCheck<TContext> Calls Database.GetPendingMigrationsAsync() on a context from the health check scope. Pending migrations: the failure status, with the names under the pendingMigrations data key. All applied but Database.HasPendingModelChanges() is true (the model changed and no migration covers it): Degraded. Otherwise Healthy
MigrationsHealthCheckBuilderExtensions.ReadyTag "ready"

A database that does not exist yet has every migration pending. When the database cannot be reached, the query throws and the health check service reports the failure status with the exception. Either way the check fails, so it also covers connectivity.

To apply the migrations at startup instead of waiting for them, use MigrateDatabaseAsync<TContext>() from CSharpEssentials.EntityFrameworkCore (see Migrate on startup).

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.0.0 0 11/28/2026