Lyo.Config.Postgres 1.0.11

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

Lyo.Config.Postgres

PostgreSQL + EF Core implementation of Lyo.Config.IConfigStore for typed configuration definitions and per-entity bindings.

What ships

  • ConfigDbContext (+ ConfigDbContextFactory) under Database/ with DbSet<ConfigDefinitionEntity>, DbSet<ConfigBindingEntity>, DbSet<ConfigBindingRevisionEntity>, and DbSet<ConfigDefinitionRevisionEntity>.
  • Fluent-API entity configurations enforcing the uniqueness rules from Lyo.Config:
  • config_definition unique on (ForEntityType, Key).
  • config_binding unique on (DefinitionId, ForEntityType, ForEntityId) with ON DELETE CASCADE from the definition row.
  • config_binding_revision keyed on (BindingId, Revision) monotonic 1-based revision numbers per binding.
  • config_definition_revision keyed on (DefinitionId, Revision) monotonic 1-based metadata snapshots per definition. Every SaveDefinitionAsync appends a row.
  • IsEncrypted on the definition plus encrypted_default_value / encrypted_value bytea columns. Encryption runs only when IConfigValueEncryptionService is registered (Config.Api / TestApi). Toggling Encrypted rewrites stored defaults and all binding revisions. TestGateway does not register encryption; it writes through ConfigApiStore HTTP to TestApi.
  • PostgresConfigStore, the singleton IConfigStore implementation backed by an IDbContextFactory<ConfigDbContext>. It also implements Lyo.Health.IHealth so the container can be probed for relational connectivity.
  • PostgresConfigOptions (SectionName = "PostgresConfig", Schema = "config", ConnectionString, EnableAutoMigrations).
  • Migrations under Migrations/ (InitialCreate baseline) using the config schema for the EF migrations history table.

DI registration (Extensions)

All entry points are exposed as IServiceCollection extensions:

Entry point What it does
AddConfigDbContextFactory(Action<PostgresConfigOptions>) Registers IOptions<PostgresConfigOptions>, AddPostgresMigrations<ConfigDbContext, PostgresConfigOptions>(), and IDbContextFactory<ConfigDbContext> (UseNpgsql + migrations history under the configured schema). DbContext only, does not register IConfigStore.
AddConfigDbContextFactoryFromConfiguration(IConfiguration, string sectionName = PostgresConfigOptions.SectionName) Same as above; binds from the configuration section (default "PostgresConfig").
AddConfigDbContextFactory(PostgresConfigOptions options) Same as above with a pre-built options instance.
AddPostgresConfigStore(Action<PostgresConfigOptions>) Calls AddConfigDbContextFactory(...) then registers IConfigStore → singleton PostgresConfigStore.
AddPostgresConfigStoreFromConfiguration(IConfiguration, string sectionName = PostgresConfigOptions.SectionName) Same as above; binds from configuration.
AddPostgresConfigStore(PostgresConfigOptions options) Same as above with a pre-built options instance, for tests / integration harnesses. Resolves optional IConfigValueEncryptionService from DI (null on workbench hosts).
AddConfigValueEncryption(keyName = ConfigQueryRoutes.EncryptionKeyName) Registers IConfigValueEncryptionService using a keyed IEncryptionService. Call on API hosts only.
AddConfigQueryServices() Registers query/CRUD-read/export services for ConfigDbContext. Call on API hosts before MapConfigQueryEndpoints.
MapConfigQueryEndpoints() Maps query/get/export for Config/Definition and Config/Binding. Writes stay on IConfigStore. DeniedSelectFields hide DefaultValueJson and EncryptedDefaultValue.

PostgresConfigOptions.ConnectionString is validated (non-empty) by all entry points. The EnableAutoMigrations flag is consumed by AddPostgresMigrations<>. See Lyo.Postgres to gate the hosted-startup migration runner.

Runtime expectations

PostgresConfigStore opens a fresh ConfigDbContext per call via the registered IDbContextFactory<ConfigDbContext>, so a singleton is safe under concurrent load. SaveDefinitionAsync upserts config_definition and appends config_definition_revision. When IsEncrypted flips, existing defaults and all config_binding_revision rows are rewritten to ciphertext or back to JSON. SaveBindingAsync appends config_binding_revision inside the same SaveChangesAsync. When IsEncrypted is set, plaintext JSON columns are cleared and ciphertext is stored in bytea. Public LoadConfigAsync decrypts so apps get usable config.

Tenancy

Bindings (and their revisions) carry a nullable tenant_id column; definitions do not. Schema is deployment-global. The config_binding unique constraint includes tenant_id, so the same definition can be bound per tenant without collision. Filtered tenant indexes (ix_config_binding_tenant, ix_config_binding_revision_tenant) back lookups.

IConfigStore binding methods (not definition methods) accept an explicit Guid? tenantId and run it through TenancyResolver.Resolve using the policy configured in PostgresConfigOptions.Tenancy (inheriting from EntityRefOptions.Mode when unset):

  • SystemOnly. Bindings are persisted with tenant_id = NULL.
  • SingleTenantDefault (default), caller value, falling back to Tenancy.DefaultTenantId then EntityRefOptions.DefaultTenantId.
  • MultiTenantStrict. Caller must supply a non-empty tenantId or the store throws.

See Lyo.EntityReference.Postgres for the policy matrix.

{
  "PostgresConfig": {
    "ConnectionString": "Host=localhost;Database=config;...",
    "Tenancy": { "Mode": "MultiTenantStrict" }
  }
}

Dependencies

Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).

  • Lyo.Api (direct, lyo)
  • Lyo.Api.Export (direct, lyo)
  • Lyo.Config (direct, lyo)
  • Lyo.Encryption (direct, lyo)
  • Lyo.EntityReference.Models (direct, lyo)
  • Lyo.EntityReference.Postgres (direct, lyo)
  • Lyo.Health (direct, lyo)
  • Lyo.Postgres (direct, lyo)
  • Microsoft.EntityFrameworkCore 10.0.5 (direct, microsoft)
  • Microsoft.EntityFrameworkCore.Design 10.0.5 (direct, microsoft)
  • Microsoft.Extensions.Configuration.Binder 10.0.5 (direct, microsoft)
  • Lyo.Api.Models (transitive, lyo)
  • Lyo.Cache (transitive, lyo)
  • Lyo.Common (transitive, lyo)
  • Lyo.Compression (transitive, lyo)
  • Lyo.DateAndTime (transitive, lyo)
  • Lyo.Diagnostic (transitive, lyo)
  • Lyo.Diagnostic.AspNetCore (transitive, lyo)
  • Lyo.Diff (transitive, lyo)
  • Lyo.Exceptions (transitive, lyo)
  • Lyo.Formatter (transitive, lyo)
  • Lyo.Hashing (transitive, lyo)
  • Lyo.KeyStore (transitive, lyo)
  • Lyo.Metrics (transitive, lyo)
  • Lyo.PackageMetadata (transitive, lyo)
  • Lyo.Query (transitive, lyo)
  • Lyo.Query.Models (transitive, lyo)
  • Lyo.Result (transitive, lyo)
  • Lyo.Streams (transitive, lyo)
  • Lyo.Validation (transitive, lyo)
  • BouncyCastle.Cryptography 2.6.2 (transitive, third-party, netstandard2.0)
  • DynamicExpresso.Core 2.19.3 (transitive, third-party)
  • EasyCompressor 2.1.0 (transitive, third-party)
  • Konscious.Security.Cryptography.Argon2 1.3.1 (transitive, third-party)
  • Microsoft.AspNetCore.OpenApi 10.0.5 (transitive, microsoft)
  • Microsoft.Bcl.AsyncInterfaces 10.0.5 (transitive, microsoft, netstandard2.0)
  • Microsoft.EntityFrameworkCore.Analyzers 10.0.5 (transitive, microsoft)
  • Microsoft.EntityFrameworkCore.Relational 10.0.5 (transitive, microsoft)
  • Microsoft.Extensions.Caching.Memory 10.0.5 (transitive, microsoft)
  • Microsoft.Extensions.DependencyInjection 10.0.5 (transitive, microsoft)
  • Microsoft.Extensions.DependencyInjection.Abstractions 10.0.5 (transitive, microsoft, net10.0, netstandard2.0)
  • Microsoft.Extensions.Hosting.Abstractions 10.0.5 (transitive, microsoft)
  • Microsoft.Extensions.Logging.Abstractions 10.0.5 (transitive, microsoft)
  • Microsoft.Extensions.Options 10.0.5 (transitive, microsoft)
  • Microsoft.Extensions.Options.ConfigurationExtensions 10.0.5 (transitive, microsoft)
  • Npgsql.EntityFrameworkCore.PostgreSQL 10.0.3 (transitive, third-party)
  • SmartFormat.NET 3.6.1 (transitive, third-party)
  • System.Buffers 4.6.1 (transitive, microsoft, netstandard2.0)
  • System.ComponentModel.Annotations 5.0.0 (transitive, microsoft)
  • System.IO.Hashing 10.0.5 (transitive, microsoft, net10.0)
  • System.Memory 4.6.3 (transitive, microsoft, netstandard2.0)
  • System.Text.Json 10.0.5 (transitive, microsoft, netstandard2.0)
  • System.Threading.Tasks.Extensions 4.6.3 (transitive, microsoft, netstandard2.0)
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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 (1)

Showing the top 1 NuGet packages that depend on Lyo.Config.Postgres:

Package Downloads
Lyo.Config.Api

Central HTTP API exposing Lyo.Config PostgreSQL-backed IConfigStore for microservices (polling-friendly ETags). Embed via AddConfigApi / MapConfigApiEndpoints.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.11 35 8/23/2026
1.0.9 45 8/22/2026
1.0.6 54 8/20/2026
1.0.4 85 8/20/2026
1.0.3 72 8/19/2026
1.0.2 65 8/19/2026
1.0.1 72 8/18/2026
1.0.0 86 8/16/2026