Lyo.Config.Postgres
1.0.1
dotnet add package Lyo.Config.Postgres --version 1.0.1
NuGet\Install-Package Lyo.Config.Postgres -Version 1.0.1
<PackageReference Include="Lyo.Config.Postgres" Version="1.0.1" />
<PackageVersion Include="Lyo.Config.Postgres" Version="1.0.1" />
<PackageReference Include="Lyo.Config.Postgres" />
paket add Lyo.Config.Postgres --version 1.0.1
#r "nuget: Lyo.Config.Postgres, 1.0.1"
#:package Lyo.Config.Postgres@1.0.1
#addin nuget:?package=Lyo.Config.Postgres&version=1.0.1
#tool nuget:?package=Lyo.Config.Postgres&version=1.0.1
Lyo.Config.Postgres
PostgreSQL + EF Core implementation of Lyo.Config.IConfigStore for storing typed configuration definitions and per-entity bindings.
What ships
ConfigDbContext(+ConfigDbContextFactory) underDatabase/withDbSet<ConfigDefinitionEntity>,DbSet<ConfigBindingEntity>, andDbSet<ConfigBindingRevisionEntity>.- Fluent-API entity configurations enforcing the uniqueness rules from
Lyo.Config: config_definitionunique on(ForEntityType, Key).config_bindingunique on(DefinitionId, ForEntityType, ForEntityId)withON DELETE CASCADEfrom the definition row.config_binding_revisionkeyed on(BindingId, Revision)— monotonic 1-based revision numbers per binding.PostgresConfigStore, the singletonIConfigStoreimplementation backed by anIDbContextFactory<ConfigDbContext>. It also implementsLyo.Health.IHealthso the container can be probed for relational connectivity.PostgresConfigOptions(SectionName = "PostgresConfig",Schema = "config",ConnectionString,EnableAutoMigrations).- Migrations under
Migrations/(InitialCreatebaseline) using theconfigschema 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. |
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 it is safe as a singleton under concurrent load. SaveBindingAsync writes the current value to config_binding and appends a new config_binding_revision row inside the same SaveChangesAsync, so revision history stays in lock-step with the latest binding value. The seeded initial migration writes revision 1 from each existing binding so history starts at deploy time.
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 withtenant_id = NULL.SingleTenantDefault(default) — caller value, falling back toTenancy.DefaultTenantIdthenEntityRefOptions.DefaultTenantId.MultiTenantStrict— caller must supply a non-emptytenantIdor the store throws.
See Lyo.EntityReference.Postgres for the full matrix.
{
"PostgresConfig": {
"ConnectionString": "Host=localhost;Database=config;...",
"Tenancy": { "Mode": "MultiTenantStrict" }
}
}
Dependencies
Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).
Lyo.Config— (direct, lyo)Lyo.EntityReference.Models— (direct, lyo)Lyo.EntityReference.Postgres— (direct, lyo)Lyo.Health— (direct, lyo)Lyo.Postgres— (direct, lyo)Microsoft.EntityFrameworkCore10.0.5— (direct, microsoft)Microsoft.EntityFrameworkCore.Design10.0.5— (direct, microsoft)Microsoft.Extensions.Configuration.Binder10.0.5— (direct, microsoft)Lyo.Common— (transitive, lyo)Lyo.Exceptions— (transitive, lyo)Microsoft.EntityFrameworkCore.Relational10.0.5— (transitive, microsoft)Microsoft.Extensions.DependencyInjection.Abstractions10.0.5— (transitive, microsoft)Microsoft.Extensions.Hosting.Abstractions10.0.5— (transitive, microsoft)Microsoft.Extensions.Logging.Abstractions10.0.5— (transitive, microsoft)Microsoft.Extensions.Options10.0.5— (transitive, microsoft)Microsoft.Extensions.Options.ConfigurationExtensions10.0.5— (transitive, microsoft)Npgsql.EntityFrameworkCore.PostgreSQL10.0.3— (transitive, third-party)System.Memory4.6.3— (transitive, microsoft, netstandard2.0)System.Text.Json10.0.5— (transitive, microsoft, netstandard2.0)
| Product | Versions 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. |
-
net10.0
- Lyo.Config (>= 1.0.1)
- Lyo.EntityReference.Models (>= 1.0.1)
- Lyo.EntityReference.Postgres (>= 1.0.1)
- Lyo.Health (>= 1.0.1)
- Lyo.Postgres (>= 1.0.1)
- Microsoft.EntityFrameworkCore (>= 10.0.5)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.5)
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.