TCIS.Pluggable.Persistence.PostgreSql 1.0.0-rc.15

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

TCIS.Pluggable.Persistence.PostgreSql

The library providing PostgreSQL connection infrastructure for TCIS, supporting a Tri-Tier Multi-tenancy architecture via PostgreSqlRlsConnectionInitializer and PostgreSqlSchemaConnectionInitializer.

📦 Installation

dotnet add package TCIS.Pluggable.Persistence.PostgreSql

🚀 Registration / Setup (Program.cs)

Register the PostgreSQL Provider:

using TCIS.Pluggable.Persistence.PostgreSql;

var builder = WebApplication.CreateBuilder(args);

// Register the Pluggable DbContext with the PostgreSQL provider
builder.Services.AddPluggablePostgreSql<MyDbContext>();

Không truyền tên connection string. Chuỗi kết nối được lấy từ Tenant Store (SOT) qua IMultiTenantContextAccessor<TenantInfo> tại thời điểm mỗi request.

Tier 2 (Schema-per-tenant): tên schema lấy từ TenantInfo.Identifier (SiteCode: TCI, CTL), không phải TenantInfo.Id. Identifier phải là SQL identifier hợp lệ — ^[a-zA-Z_][a-zA-Z0-9_]{0,62}$, không chứa dấu -.

🔒 Tier 2 — search_path KHÔNG có schema dự phòng (mặc định)

PostgreSqlSchemaConnectionInitializer mặc định chỉ đặt schema của tenant:

SET search_path TO "tci"

Không có fallback. Tenant nào thiếu bảng — thường do chưa chạy migration — sẽ nhận lỗi relation does not exist ngay, thay vì âm thầm đọc dữ liệu ở schema khác.

Trước 07/08/2026, initializer luôn thêm public vào cuối search_path. Điều đó khiến một tenant thiếu bảng im lặng đọc dữ liệu ở public — nếu public lỡ chứa bảng nghiệp vụ (migration chạy nhầm schema chẳng hạn) thì mọi tenant đều đọc được, và không có tín hiệu nào báo.

Khi nào cần khai báo schema dự phòng

// Extension (pgcrypto, uuid-ossp…) cài ở public và code gọi hàm không schema-qualify
new PostgreSqlSchemaConnectionInitializer("public")
// -> SET search_path TO "tci", public

// Dữ liệu tham chiếu dùng chung nằm ở schema riêng
new PostgreSqlSchemaConnectionInitializer("shared")
// -> SET search_path TO "tci", shared

Mọi schema đưa vào danh sách dự phòng đều trở thành nơi truy vấn có thể rơi vào. Tuyệt đối không đưa vào schema có chứa bảng nghiệp vụ mang dữ liệu.

Tên schema dự phòng cũng đi thẳng vào câu lệnh SQL nên phải qua cùng regex whitelist; sai định dạng là ném lỗi ngay lúc khởi tạo, không đợi tới lúc mở kết nối.

Bảng của tenant luôn thắng schema dự phòng, vì nó đứng trước trong search_path.

Product 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. 
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
1.0.0-rc.15 0 8/12/2026
1.0.0-rc.14 0 8/12/2026
1.0.0-rc.13 35 8/11/2026
1.0.0-rc.12 46 8/10/2026
1.0.0-rc.11 61 7/28/2026
1.0.0-rc.10 51 7/24/2026
1.0.0-rc.9 51 7/21/2026
1.0.0-rc.8 51 7/21/2026