Aspire.Hosting.PostgreSQL
13.2.4
Prefix Reserved
dotnet add package Aspire.Hosting.PostgreSQL --version 13.2.4
NuGet\Install-Package Aspire.Hosting.PostgreSQL -Version 13.2.4
<PackageReference Include="Aspire.Hosting.PostgreSQL" Version="13.2.4" />
<PackageVersion Include="Aspire.Hosting.PostgreSQL" Version="13.2.4" />
<PackageReference Include="Aspire.Hosting.PostgreSQL" />
paket add Aspire.Hosting.PostgreSQL --version 13.2.4
#r "nuget: Aspire.Hosting.PostgreSQL, 13.2.4"
#:package Aspire.Hosting.PostgreSQL@13.2.4
#addin nuget:?package=Aspire.Hosting.PostgreSQL&version=13.2.4
#tool nuget:?package=Aspire.Hosting.PostgreSQL&version=13.2.4
Aspire.Hosting.PostgreSQL library
Provides extension methods and resource definitions for an Aspire AppHost to configure a PostgreSQL resource.
Getting started
Install the package
In your AppHost project, install the Aspire PostgreSQL Hosting library with NuGet:
dotnet add package Aspire.Hosting.PostgreSQL
Usage example
Then, in the AppHost.cs file of AppHost, add a PostgreSQL resource and consume the connection using the following methods:
var db = builder.AddPostgres("pgsql").AddDatabase("mydb");
var myService = builder.AddProject<Projects.MyService>()
.WithReference(db);
Connection Properties
When you reference a PostgreSQL resource using WithReference, the following connection properties are made available to the consuming project:
PostgreSQL server
The PostgreSQL server resource exposes the following connection properties:
| Property Name | Description |
|---|---|
Host |
The hostname or IP address of the PostgreSQL server |
Port |
The port number the PostgreSQL server is listening on |
Username |
The username for authentication |
Password |
The password for authentication |
Uri |
The connection URI in postgresql:// format, with the format postgresql://{Username}:{Password}@{Host}:{Port} |
JdbcConnectionString |
JDBC-format connection string, with the format jdbc:postgresql://{Host}:{Port}. User and password credentials are provided as separate Username and Password properties. |
PostgreSQL database
The PostgreSQL database resource inherits all properties from its parent PostgresServerResource and adds:
| Property Name | Description |
|---|---|
Uri |
The connection URI with the database name, with the format postgresql://{Username}:{Password}@{Host}:{Port}/{DatabaseName} |
JdbcConnectionString |
JDBC connection string with database name, with the format jdbc:postgresql://{Host}:{Port}/{DatabaseName}. User and password credentials are provided as separate Username and Password properties. |
DatabaseName |
The name of the database |
Aspire exposes each property as an environment variable named [RESOURCE]_[PROPERTY]. For instance, the Uri property of a resource called db1 becomes DB1_URI.
MCP (Model Context Protocol) Support
The PostgreSQL hosting integration provides support for adding an MCP sidecar container that enables AI agents to interact with PostgreSQL databases. This is enabled by calling WithPostgresMcp() on a PostgreSQL database resource.
var db = builder.AddPostgres("pg")
.AddDatabase("mydb")
.WithPostgresMcp();
The PostgreSQL MCP server is currently powered by Postgres MCP Pro) and provides tools for database exploration, query execution, index tuning, and health checks.
Additional documentation
https://aspire.dev/integrations/databases/postgres/postgres-get-started/ https://aspire.dev/integrations/databases/efcore/postgresql/
Feedback & contributing
https://github.com/microsoft/aspire
*Postgres, PostgreSQL and the Slonik Logo are trademarks or registered trademarks of the PostgreSQL Community Association of Canada, and used with their permission.
| Product | Versions 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 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. net10.0 was computed. 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. |
-
net8.0
- Aspire.Hosting (>= 13.2.4)
- AspNetCore.HealthChecks.NpgSql (>= 9.0.0)
- AspNetCore.HealthChecks.Uris (>= 9.0.0)
- Google.Protobuf (>= 3.33.5)
- Grpc.AspNetCore (>= 2.76.0)
- Grpc.Net.ClientFactory (>= 2.76.0)
- Grpc.Tools (>= 2.78.0)
- Humanizer.Core (>= 2.14.1)
- JsonPatch.Net (>= 3.3.0)
- KubernetesClient (>= 18.0.13)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.5)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 8.0.25)
- Microsoft.Extensions.FileSystemGlobbing (>= 10.0.5)
- Microsoft.Extensions.Hosting (>= 10.0.5)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Http (>= 10.0.5)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Options (>= 10.0.5)
- Microsoft.Extensions.Primitives (>= 10.0.5)
- ModelContextProtocol (>= 1.0.0)
- Newtonsoft.Json (>= 13.0.4)
- Polly.Core (>= 8.6.5)
- Semver (>= 3.0.0)
- StreamJsonRpc (>= 2.22.23)
- System.IO.Hashing (>= 10.0.3)
- System.Text.Json (>= 10.0.5)
NuGet packages (20)
Showing the top 5 NuGet packages that depend on Aspire.Hosting.PostgreSQL:
| Package | Downloads |
|---|---|
|
Aspire.Hosting.Azure.PostgreSQL
Azure PostgreSql Flexible Server resource types for Aspire. |
|
|
CommunityToolkit.Aspire.Hosting.PostgreSQL.Extensions
An Aspire integration for extending postgres hosting. |
|
|
CommunityToolkit.Aspire.Hosting.Keycloak.Extensions
Aspire hosting extensions for Keycloak (includes PostgreSQL integration). |
|
|
Altemiq.Aspire.Hosting.PostgreSQL.Extensions
PostgreSQL support for .NET Aspire. |
|
|
Altemiq.Aspire.Hosting.PostGIS
PostGIS support for .NET Aspire. |
GitHub repositories (48)
Showing the top 20 popular GitHub repositories that depend on Aspire.Hosting.PostgreSQL:
| Repository | Stars |
|---|---|
|
dotnet/eShop
A reference .NET application implementing an eCommerce site
|
|
|
fullstackhero/dotnet-starter-kit
Production Grade Cloud-Ready .NET 10 Starter Kit (Web API + Blazor Client) with Multitenancy Support, and Clean/Modular Architecture that saves roughly 200+ Development Hours! All Batteries Included.
|
|
|
ChilliCream/graphql-platform
Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Nitro the awesome Monaco based GraphQL IDE.
|
|
|
thomhurst/TUnit
A modern, fast and flexible .NET testing framework
|
|
|
oskardudycz/EventSourcing.NetCore
Examples and Tutorials of Event Sourcing in .NET
|
|
|
evolutionary-architecture/evolutionary-architecture-by-example
Navigate the complex landscape of .NET software architecture with our step-by-step, story-like guide. Unpack the interplay between modular monoliths, microservices, domain-driven design, and various architectural patterns. Go beyond the one-size-fits-all solutions and understand how to blend these approaches based on your unique needs.
|
|
|
Nethereum/Nethereum
Ethereum .Net cross platform integration library
|
|
|
GZTimeWalker/GZCTF
The GZ::CTF project, an open source CTF platform.
|
|
|
Azure/data-api-builder
Data API builder provides modern REST, GraphQL endpoints and MCP tools to your Azure Databases and on-prem stores.
|
|
|
bitfoundation/bitplatform
Build all of your apps using what you already know and love ❤️
|
|
|
meysamhadeli/booking-microservices
A practical microservices with the latest technologies and architectures like Vertical Slice Architecture, Event Sourcing, CQRS, DDD, gRpc, MongoDB, RabbitMq, Masstransit, and Aspire in .Net 10.
|
|
|
abpframework/abp-samples
Sample solutions built with the ABP Framework
|
|
|
microsoft/aspire-samples
|
|
|
tonybaloney/CSnakes
Embed Python in .NET
|
|
|
colinin/abp-next-admin
这是基于vue-vben-admin 模板适用于abp vNext的前端管理项目
|
|
|
mehdihadeli/food-delivery-microservices
🍔 A practical and cloud-native food delivery microservices, built with .Net Aspire, .Net 9, MassTransit, Domain-Driven Design, CQRS, Vertical Slice Architecture, Event-Driven Architecture, and the latest technologies.
|
|
|
cmu-sei/GHOSTS
GHOSTS is a realistic user simulation framework for cyber experimentation, simulation, training, and exercise
|
|
|
CommunityToolkit/Aspire
A community project with additional components and extensions for Aspire
|
|
|
meysamhadeli/booking-modular-monolith
A practical Modular Monolith architecture with the latest technologies and architecture like Vertical Slice Architecture, Event Driven Architecture, CQRS, DDD, gRpc, Masstransit, and Aspire in .Net 10.
|
|
|
mehmetozkaya/Design-Microservices-Architecture-with-Patterns-Principles
Design Microservices Architecture with Patterns & Principles. Design Microservices Architecture with Design Patterns, Principles and the Best Practices. How to handle millions of request with designing system for high availability, high scalability, low latency, and resilience to network failures on distributed microservices.
|
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 13.2.4 | 8,264 | 4/24/2026 | |
| 13.2.3 | 16,587 | 4/21/2026 | |
| 13.2.2 | 84,059 | 4/8/2026 | |
| 13.2.1 | 70,306 | 3/31/2026 | |
| 13.2.0 | 129,384 | 3/23/2026 | |
| 13.1.3 | 46,456 | 3/19/2026 | |
| 13.1.2 | 228,541 | 2/26/2026 | |
| 13.1.1 | 151,003 | 2/11/2026 | |
| 13.1.0 | 560,729 | 12/17/2025 | |
| 13.0.2 | 109,927 | 12/4/2025 | |
| 13.0.1 | 58,751 | 11/26/2025 | |
| 13.0.0 | 135,490 | 11/11/2025 | |
| 9.5.2 | 311,328 | 10/23/2025 | |
| 9.5.1 | 134,696 | 10/3/2025 | |
| 9.5.0 | 64,974 | 9/25/2025 | |
| 9.4.2 | 122,444 | 9/2/2025 | |
| 9.4.1 | 100,926 | 8/12/2025 | |
| 9.4.0 | 94,712 | 7/29/2025 | |
| 9.3.1 | 221,454 | 6/10/2025 | |
| 9.3.0 | 134,141 | 5/19/2025 |