Lewee.Infrastructure.PostgreSQL
0.40.3
dotnet add package Lewee.Infrastructure.PostgreSQL --version 0.40.3
NuGet\Install-Package Lewee.Infrastructure.PostgreSQL -Version 0.40.3
<PackageReference Include="Lewee.Infrastructure.PostgreSQL" Version="0.40.3" />
<PackageVersion Include="Lewee.Infrastructure.PostgreSQL" Version="0.40.3" />
<PackageReference Include="Lewee.Infrastructure.PostgreSQL" />
paket add Lewee.Infrastructure.PostgreSQL --version 0.40.3
#r "nuget: Lewee.Infrastructure.PostgreSQL, 0.40.3"
#:package Lewee.Infrastructure.PostgreSQL@0.40.3
#addin nuget:?package=Lewee.Infrastructure.PostgreSQL&version=0.40.3
#tool nuget:?package=Lewee.Infrastructure.PostgreSQL&version=0.40.3
Lewee.Infrastructure.PostgreSQL
PostgreSQL-specific database configuration for Entity Framework Core with Npgsql.
Purpose
This package provides PostgreSQL-specific configuration for Entity Framework Core, extending the base database functionality from Lewee.Infrastructure.Data. It handles Npgsql setup, schema support, migration history table configuration, and exception processing.
Dependencies
Lewee.Infrastructure.Data- Base Entity Framework configurationNpgsql.EntityFrameworkCore.PostgreSQL- PostgreSQL provider for EF CoreEntityFrameworkCore.Exceptions.PostgreSQL- Exception processor for PostgreSQL
Components
PostgreSqlConfiguration
Static configuration class with the AddLeweePostgreSQL extension method for registering PostgreSQL database contexts.
Key Features:
- Configures Npgsql as the database provider
- Supports optional schema specification for multi-tenant scenarios
- Configures migrations history table within the specified schema
- Integrates
EntityFrameworkCore.Exceptions.PostgreSQLfor better exception handling - Automatically adds audit and domain event interceptors from
Lewee.Infrastructure.Data
Configuration
using Lewee.Infrastructure.PostgreSQL;
// Basic configuration (default schema)
services.AddLeweePostgreSQL<MyDbContext>(
connectionString: "Host=localhost;Database=mydb;...",
domainAssembly: typeof(MyDomainEntity).Assembly);
// Configuration with schema (for multi-tenant scenarios)
services.AddLeweePostgreSQL<MyDbContext>(
connectionString: "Host=localhost;Database=mydb;...",
domainAssembly: typeof(MyDomainEntity).Assembly,
schema: "tenant1");
Features
Schema Support
When a schema is specified:
- The migrations history table (
__EFMigrationsHistory) is placed within the specified schema - Useful for multi-tenant applications with schema-per-tenant isolation
Exception Processing
Uses EntityFrameworkCore.Exceptions.PostgreSQL to convert PostgreSQL-specific exceptions into more meaningful .NET exceptions, improving error handling for:
- Unique constraint violations
- Foreign key violations
- Not null constraint violations
Interceptor Integration
Automatically configures the following interceptors from Lewee.Infrastructure.Data:
AuditDetailsSaveChangesInterceptor- Populates created/modified audit fieldsDomainEventSaveChangesInterceptor- Dispatches domain events after save
Sample Usage
See the Pizzeria Store Data project for a complete implementation example with PostgreSQL.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- EntityFrameworkCore.Exceptions.PostgreSQL (>= 11.0.0)
- Lewee.Infrastructure.Data (>= 0.40.3)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 11.0.0)
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 |
|---|---|---|
| 0.40.3 | 51 | 11/22/2026 |