PostgreSQL Provider
The PostgreSQL provider offers full relational database support with Npgsql-based query execution, event sourcing integration, inbox/outbox patterns, and Change Data Capture.
Before You Start
- .NET 8.0+ (or .NET 9/10 for latest features)
- A PostgreSQL instance (local or cloud-hosted)
- Familiarity with data access and IDb interface
Installation
dotnet add package Excalibur.Data.Postgres
Dependencies: Excalibur.Data.Abstractions, Npgsql
Quick Start
using Microsoft.Extensions.DependencyInjection;
services.AddPostgresDataExecutors(() => new NpgsqlConnection(connectionString));
Registration Options
Data Executors
services.AddPostgresDataExecutors(() => new NpgsqlConnection(connectionString));
Event Store
// With connection string
services.AddPostgresEventStore(connectionString);
// With connection string and options
services.AddPostgresEventStore(connectionString, options =>
{
options.SchemaName = "events";
});
Snapshot Store
services.AddPostgresSnapshotStore(connectionString);
Inbox / Outbox
services.AddPostgresInboxStore(options =>
{
options.ConnectionString = connectionString;
});
Change Data Capture
services.AddPostgresCdc(options =>
{
options.ConnectionString = connectionString;
options.PublicationName = "my_publication";
options.ReplicationSlotName = "my_slot";
});
Data Request Pattern
public class GetCustomerRequest : DataRequest<Customer?>
{
public GetCustomerRequest(Guid customerId)
{
Command = new CommandDefinition(
"SELECT * FROM customers WHERE id = @Id",
new { Id = customerId });
}
}
See Also
- Data Providers Overview — Architecture and core abstractions
- SQL Server Provider — Microsoft SQL Server alternative
- Event Sourcing — PostgreSQL event store integration