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
                    
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="Lewee.Infrastructure.PostgreSQL" Version="0.40.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Lewee.Infrastructure.PostgreSQL" Version="0.40.3" />
                    
Directory.Packages.props
<PackageReference Include="Lewee.Infrastructure.PostgreSQL" />
                    
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 Lewee.Infrastructure.PostgreSQL --version 0.40.3
                    
#r "nuget: Lewee.Infrastructure.PostgreSQL, 0.40.3"
                    
#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 Lewee.Infrastructure.PostgreSQL@0.40.3
                    
#: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=Lewee.Infrastructure.PostgreSQL&version=0.40.3
                    
Install as a Cake Addin
#tool nuget:?package=Lewee.Infrastructure.PostgreSQL&version=0.40.3
                    
Install as a Cake Tool

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 configuration
  • Npgsql.EntityFrameworkCore.PostgreSQL - PostgreSQL provider for EF Core
  • EntityFrameworkCore.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.PostgreSQL for 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 fields
  • DomainEventSaveChangesInterceptor - Dispatches domain events after save

Sample Usage

See the Pizzeria Store Data project for a complete implementation example with PostgreSQL.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
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
0.40.3 51 11/22/2026