EntglDb.Persistence.PostgreSQL 0.9.1

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

EntglDb.Persistence.PostgreSQL

PostgreSQL persistence provider for EntglDb with native JSONB support and GIN indexes.

Features

  • JSONB Native Storage: Stores document content as PostgreSQL JSONB
  • GIN Indexes: Supports fast JSON path queries
  • Connection Resilience: Built-in retry logic for transient failures
  • High Performance: Optimized for production workloads
  • Full ACID: Leverages PostgreSQL's transaction guarantees

Installation

dotnet add package EntglDb.Persistence.PostgreSQL

Quick Start

services.AddEntglDbPostgreSql(
    "Host=localhost;Database=EntglDb;Username=user;Password=pass");

Advanced Configuration

services.AddEntglDbPostgreSql(connectionString, options =>
{
    options.EnableSensitiveDataLogging(); // Dev only
    options.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
    options.CommandTimeout(30); // 30 second timeout
});

Migrations

Create and apply migrations using EF Core tools:

# Install EF Core tools
dotnet tool install --global dotnet-ef

# Add initial migration
dotnet ef migrations add InitialCreate --context PostgreSqlDbContext

# Update database
dotnet ef database update --context PostgreSqlDbContext

JSONB Indexes

For optimal performance, create GIN indexes on JSON columns via migrations:

// In your migration file:
protected override void Up(MigrationBuilder migrationBuilder)
{
    migrationBuilder.Sql(@"
        CREATE INDEX IF NOT EXISTS IX_Documents_ContentJson_gin 
        ON ""Documents"" USING GIN (""ContentJson"" jsonb_path_ops);
        
        CREATE INDEX IF NOT EXISTS IX_Oplog_PayloadJson_gin 
        ON ""Oplog"" USING GIN (""PayloadJson"" jsonb_path_ops);
    ");
}

JSONB Queries (Future)

PostgreSQL provider will support native JSONB queries:

// Future feature - not yet implemented
var docs = await store.QueryDocumentsAsync("users", 
    new PropertyEquals("status", "active"));
// Translates to: WHERE ContentJson @> '{"status": "active"}'

Connection String Format

Host=localhost;Port=5432;Database=EntglDb;Username=admin;Password=secret

With SSL

Host=prod-db.example.com;Database=EntglDb;Username=admin;Password=secret;SSL Mode=Require

Connection Pooling

Host=localhost;Database=EntglDb;Username=admin;Password=secret;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=100

Performance Tips

  1. Enable Connection Pooling: Always use pooling in production
  2. Create GIN Indexes: Essential for fast JSON queries
  3. Monitor Query Performance: Use EXPLAIN ANALYZE on complex queries
  4. Tune PostgreSQL: Adjust shared_buffers, work_mem for your workload

Comparison with Other Providers

Feature SQLite (Direct) EF Core Generic PostgreSQL
JSON Storage TEXT NVARCHAR/TEXT JSONB
JSON Queries json_extract In-Memory Native (@>, ?, etc)
Indexing Standard Standard GIN/GIST
Scalability Single Node Medium High
Production Ready Yes Yes Yes

When to Use PostgreSQL

Use PostgreSQL when:

  • You need advanced JSON querying capabilities
  • Running high-traffic production workloads
  • Require horizontal scaling (with replication)
  • Need complex indexing strategies
  • Want full ACID compliance with high concurrency

Use SQLite when:

  • Building single-node applications
  • Maximum simplicity is priority
  • Embedded scenarios

Use EF Core Generic when:

  • You need multi-database support
  • Your team prefers ORM patterns

License

MIT

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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.  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. 
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.9.1 88 1/28/2026
0.8.6 82 1/27/2026
0.8.5 82 1/26/2026
0.8.4 93 1/22/2026
0.8.3 85 1/22/2026
0.8.2 81 1/21/2026
0.8.1 82 1/21/2026
0.8.0 82 1/21/2026