Lyo.Postgres
1.0.0
See the version list below for details.
dotnet add package Lyo.Postgres --version 1.0.0
NuGet\Install-Package Lyo.Postgres -Version 1.0.0
<PackageReference Include="Lyo.Postgres" Version="1.0.0" />
<PackageVersion Include="Lyo.Postgres" Version="1.0.0" />
<PackageReference Include="Lyo.Postgres" />
paket add Lyo.Postgres --version 1.0.0
#r "nuget: Lyo.Postgres, 1.0.0"
#:package Lyo.Postgres@1.0.0
#addin nuget:?package=Lyo.Postgres&version=1.0.0
#tool nuget:?package=Lyo.Postgres&version=1.0.0
Lyo.Postgres
Shared PostgreSQL migration plumbing for Lyo libraries that ship their own EF Core schema (Audit, Email, ChangeTracker, EntityReference, etc.). The package is a thin IHostedService that runs DbContext.Database.MigrateAsync at host startup when the consumer’s options opt in.
Out of scope: this package does not ship health checks, design-time
IDesignTimeDbContextFactoryhelpers, or connection-string builders. Those live in the consumer > libraries (e.g.Lyo.Audit.Postgres,Lyo.Email.Postgres) when needed.
Examples
Usage
using Lyo.Postgres;
using Microsoft.Extensions.DependencyInjection;
public sealed class AuditDbOptions : IPostgresMigrationConfig
{
public string ConnectionString { get; init; } = "";
public bool EnableAutoMigrations { get; init; }
public string Schema { get; init; } = "audit";
}
services.Configure<AuditDbOptions>(configuration.GetSection("Audit:Postgres"));
services.AddPostgresMigrations<AuditDbContext, AuditDbOptions>();
Public API
| Type | Role |
|---|---|
IPostgresMigrationConfig |
Contract for options classes that want to opt into hosted migrations. Members: string ConnectionString, bool EnableAutoMigrations, string Schema. |
PostgresMigrationHostedService<TContext, TOptions> |
IHostedService that, on StartAsync, scopes a fresh TContext over the configured connection string, runs CREATE SCHEMA IF NOT EXISTS "<Schema>", then MigrateAsync. |
Extensions.AddPostgresMigrations<TContext, TOptions>() |
Registers the hosted service. Both type parameters are constrained: TContext : DbContext, TOptions : class, IPostgresMigrationConfig. |
The hosted service activates a TContext instance via Activator.CreateInstance(typeof(TContext), dbContextOptions), so each consumer DbContext must expose a public
constructor that takes a single DbContextOptions<TContext>. The migrations history table is stored in the schema returned by IPostgresMigrationConfig.Schema as
"<schema>"."__EFMigrationsHistory".
StartAsync short-circuits when EnableAutoMigrations is false. If the flag is true, both ConnectionString and Schema are required (whitespace throws via
Lyo.Exceptions.ArgumentHelpers).
Usage
- The hosted service resolves
IOptions<AuditDbOptions>. - If
EnableAutoMigrationsis false, it returns immediately. - Otherwise it constructs an
AuditDbContextwithUseNpgsql(connectionString, opt => opt.MigrationsHistoryTable("__EFMigrationsHistory", schema)). - It executes
CREATE SCHEMA IF NOT EXISTS "<schema>"(the schema name is escaped by doubling embedded"characters before interpolation). - It runs
Database.MigrateAsync(ct).
Consumers
Lyo.Audit.PostgresLyo.Email.PostgresLyo.ChangeTracker.PostgresLyo.EntityReference.PostgresLyo.FileMetadataStore.Postgres
Dependencies
Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).
Lyo.Exceptions— (direct, lyo)Microsoft.EntityFrameworkCore10.0.5— (direct, microsoft)Microsoft.EntityFrameworkCore.Design10.0.5— (direct, microsoft)Microsoft.EntityFrameworkCore.Relational10.0.5— (direct, microsoft)Microsoft.Extensions.Hosting.Abstractions10.0.5— (direct, microsoft)Microsoft.Extensions.Options10.0.5— (direct, microsoft)Npgsql.EntityFrameworkCore.PostgreSQL10.0.3— (direct, third-party)
| 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.Exceptions (>= 1.0.0)
- Microsoft.EntityFrameworkCore (>= 10.0.5)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.5)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Options (>= 10.0.5)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 10.0.3)
NuGet packages (26)
Showing the top 5 NuGet packages that depend on Lyo.Postgres:
| Package | Downloads |
|---|---|
|
Lyo.EntityReference.Postgres
Entity Framework Core base entity, configuration, and store helpers for canonical entity-ref rows on PostgreSQL. |
|
|
Lyo.Sms.Postgres
PostgreSQL implementation of Lyo.Sms using Entity Framework Core. |
|
|
Lyo.Email.Postgres
PostgreSQL schema and entities for email logging. Consumers map EmailSent events and insert into email_logs / email_attachment_logs. |
|
|
Lyo.FileMetadataStore.Postgres
PostgreSQL implementation of the Lyo FileMetadataStore service using Entity Framework Core. |
|
|
Lyo.Job.Postgres
PostgreSQL job management data layer with EF Core, optional auto-migrations, and API endpoints for scheduling, running, and monitoring background jobs with RabbitMQ support. |
GitHub repositories
This package is not used by any popular GitHub repositories.