AspNetCore.HealthChecks.NpgSql 9.0.0

Prefix Reserved
dotnet add package AspNetCore.HealthChecks.NpgSql --version 9.0.0
                    
NuGet\Install-Package AspNetCore.HealthChecks.NpgSql -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="AspNetCore.HealthChecks.NpgSql" Version="9.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AspNetCore.HealthChecks.NpgSql" Version="9.0.0" />
                    
Directory.Packages.props
<PackageReference Include="AspNetCore.HealthChecks.NpgSql" />
                    
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 AspNetCore.HealthChecks.NpgSql --version 9.0.0
                    
#r "nuget: AspNetCore.HealthChecks.NpgSql, 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.
#addin nuget:?package=AspNetCore.HealthChecks.NpgSql&version=9.0.0
                    
Install AspNetCore.HealthChecks.NpgSql as a Cake Addin
#tool nuget:?package=AspNetCore.HealthChecks.NpgSql&version=9.0.0
                    
Install AspNetCore.HealthChecks.NpgSql as a Cake Tool

PostgreSQL Health Check

This health check verifies the ability to communicate with PostgreSQL. It uses the Npgsql library.

NpgsqlDataSource

Starting with Npgsql 7.0 (and .NET 7), the starting point for any database operation is NpgsqlDataSource. The data source represents your PostgreSQL database, and can hand out connections to it, or support direct execution of SQL against it. The data source encapsulates the various Npgsql configuration needed to connect to PostgreSQL, as well as the connection pooling which makes Npgsql efficient.

Npgsql's data source supports additional configuration beyond the connection string, such as logging, advanced authentication options, type mapping management, and more.

To take advantage of the performance NpgsqlDataSource has to offer, it should be used as a singleton. Otherwise, the app might end up with having multiple data source instances, all of which would have their own connection pools. This can lead to resources exhaustion and major performance issues (Example: #1993).

We encourage you to use Npgsql.DependencyInjection package for registering a singleton factory for NpgsqlDataSource. It allows easy configuration of your Npgsql connections and registers the appropriate services in your DI container.

To make the shift to NpgsqlDataSource as easy as possible, the Npgsql.DependencyInjection package registers not just a factory for the data source, but also factory for NpgsqlConnection (and even DbConnection). So, your app does not need to suddenly start using NpgsqlDataSource everywhere.

void Configure(IServiceCollection services)
{
    services.AddNpgsqlDataSource("Host=pg_server;Username=test;Password=test;Database=test");
    services.AddHealthChecks().AddNpgSql();
}

By default, the NpgsqlDataSource instance is resolved from service provider. If you need to access more than one PostgreSQL database, you can use keyed DI services to achieve that:

void Configure(IServiceCollection services)
{
    services.AddNpgsqlDataSource("Host=pg_server;Username=test;Password=test;Database=first", serviceKey: "first");
    services.AddHealthChecks().AddNpgSql(sp => sp.GetRequiredKeyedService<NpgsqlDataSource>("first"));

    services.AddNpgsqlDataSource("Host=pg_server;Username=test;Password=test;Database=second", serviceKey: "second");
    services.AddHealthChecks().AddNpgSql(sp => sp.GetRequiredKeyedService<NpgsqlDataSource>("second"));
}

Connection String

Raw connection string is of course still supported:

services.AddHealthChecks().AddNpgSql("Host=pg_server;Username=test;Password=test;Database=test");
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (68)

Showing the top 5 NuGet packages that depend on AspNetCore.HealthChecks.NpgSql:

Package Downloads
Reo.Core.Database

Package Description

Reo.Core.Testing

Package Description

Aspire.Hosting.PostgreSQL

PostgreSQL® support for .NET Aspire.

Reo.Core.IntegrationTesting

Package Description

Aspire.Npgsql

A PostgreSQL® client that integrates with Aspire, including health checks, metrics, logging, and telemetry.

GitHub repositories (24)

Showing the top 20 popular GitHub repositories that depend on AspNetCore.HealthChecks.NpgSql:

Repository Stars
dotnet/aspire
Tools, templates, and packages to accelerate building observable, production-ready apps
Ombi-app/Ombi
Want a Movie or TV Show on Plex/Emby/Jellyfin? Use Ombi!
skoruba/IdentityServer4.Admin
The administration for the IdentityServer4 and Asp.Net Core Identity
aspnetrun/run-aspnetcore-microservices
Microservices on .NET platforms used ASP.NET Web API, Docker, RabbitMQ, MassTransit, Grpc, Yarp API Gateway, PostgreSQL, Redis, SQLite, SqlServer, Marten, Entity Framework Core, CQRS, MediatR, DDD, Vertical and Clean Architecture implementation with using latest features of .NET 8 and C# 12
dotnetcore/osharp
OSharp是一个基于.Net6.0的快速开发框架,框架对 AspNetCore 的配置、依赖注入、日志、缓存、实体框架、Mvc(WebApi)、身份认证、功能权限、数据权限等模块进行更高一级的自动化封装,并规范了一套业务实现的代码结构与操作流程,使 .Net 框架更易于应用到实际项目开发中。
featbit/featbit
Enterprise-grade feature flag platform that you can self-host. Get started - free.
IoTSharp/IoTSharp
IoTSharp is an open-source IoT platform for data collection, processing, visualization, and device management.
desenvolvedor-io/dev-store
A microservices e-commerce reference application built with ASP.NET 6
meysamhadeli/monolith-to-cloud-architecture
A practical architecture styles for migrating from monolith to modern cloud native application with the latest technologies and architectures like Vertical Slice Architecture, Event Sourcing, CQRS, DDD, gRpc, MongoDB, RabbitMq, and Masstransit in .Net 9.
mehdihadeli/food-delivery-microservices
🍔 A practical and imaginary food delivery microservices, built with .Net 9, MassTransit, Domain-Driven Design, CQRS, Vertical Slice Architecture, Event-Driven Architecture, and the latest technologies.
chayxana/Restaurant-App
Restaurant App 🍔 is a sample open-source e-Commerce 🛒 application for ordering foods, powered by polyglot microservices architecture and cross-platform development including mobile and web
skoruba/Duende.IdentityServer.Admin
The administration for the Duende IdentityServer and Asp.Net Core Identity ⚡
Implem/Implem.Pleasanter
Pleasanter is a no-code/low-code development platform that runs on .NET. You can quickly create business applications with simple operations.
dotnet/dotnet
Home of .NET's Virtual Monolithic Repository which includes all the code needed to build the .NET SDK.
thangchung/practical-dotnet-aspire
The practical .NET Aspire builds on the coffeeshop app business domain
proudmonkey/ApiBoilerPlate
A simple yet organized project template for building ASP.NET Core APIs in .NET Core 3.1
mehdihadeli/food-delivery-modular-monolith
🌭 A practical and imaginary food and grocery delivery modular monolith, built with .Net 8, Domain-Driven Design, CQRS, Vertical Slice Architecture, Event-Driven Architecture, and the latest technologies.
mehdihadeli/vertical-slice-api-template
🍰 An asp.net core template based on .Net 9, Vertical Slice Architecture, CQRS, Minimal APIs, OpenTelemetry, API Versioning and OpenAPI.
poorna-soysa/books-api-docker-compose-postgresql-redis
This repository showcases a sample API built with .NET 8, designed to demonstrate the integration of Docker Compose for container orchestration. The application utilizes PostgreSQL as its primary database and Redis for caching, providing a robust foundation for scalable web services
mehmetozkaya/EShopMicroservices
Version Downloads Last updated
9.0.0 859,625 12/19/2024
8.0.2 3,434,957 8/29/2024
8.0.1 3,609,956 4/2/2024
8.0.0 1,704,144 12/15/2023
7.1.0 1,452,973 10/3/2023
7.0.0 922,447 7/30/2023
7.0.0-rc2.7 67,050 3/13/2023
7.0.0-rc2.6 39,834 1/14/2023
7.0.0-rc2.5 23,949 12/27/2022
7.0.0-rc2.4 464 12/27/2022
6.0.2 10,972,079 2/28/2022
6.0.1 992,957 12/29/2021
6.0.1-rc2.3 36,936 11/10/2021
6.0.1-rc1.2 2,383 11/5/2021
6.0.0 116,415 12/29/2021
5.0.2 3,348,892 3/8/2021
5.0.1 476,683 1/5/2021
5.0.0 33,804 12/29/2020
5.0.0-preview1 9,328 11/22/2020
3.1.1 3,266,534 4/17/2020
3.1.0 369,983 4/9/2020
3.0.0 909,261 9/24/2019
2.2.1 509,136 6/6/2019
2.2.0 392,950 11/14/2018