MagicCSharp.Data.Postgres
1.0.0
See the version list below for details.
dotnet add package MagicCSharp.Data.Postgres --version 1.0.0
NuGet\Install-Package MagicCSharp.Data.Postgres -Version 1.0.0
<PackageReference Include="MagicCSharp.Data.Postgres" Version="1.0.0" />
<PackageVersion Include="MagicCSharp.Data.Postgres" Version="1.0.0" />
<PackageReference Include="MagicCSharp.Data.Postgres" />
paket add MagicCSharp.Data.Postgres --version 1.0.0
#r "nuget: MagicCSharp.Data.Postgres, 1.0.0"
#:package MagicCSharp.Data.Postgres@1.0.0
#addin nuget:?package=MagicCSharp.Data.Postgres&version=1.0.0
#tool nuget:?package=MagicCSharp.Data.Postgres&version=1.0.0
MagicCSharp.Data.Postgres
PostgreSQL wiring for MagicCSharp.Data.EntityFramework.
Registration
builder.Services.AddPostgresDbContextFactory<MagicShopContext>(builder.Configuration);
Reads DB_HOST, DB_PORT, DB_NAME, DB_USER and DB_PASSWORD. Each is required — a missing one throws
rather than quietly defaulting to localhost. Pass a different configPrefix to point a second context at
another database.
Registers a pooled factory, which is what makes the repositories' context-per-operation cheap. Opens one connection during registration, so a wrong host or password fails at startup instead of on the first request that needs the database.
Pool sizes, timeouts and retry live in PostgresConnectionOptions. Size MaxPoolSize against the server's
limit divided by the number of instances you run, or a rolling deploy will exhaust the server.
Migrations
public class MagicShopContextFactory() : MagicDbContextFactory<MagicShopContext>("shop");
dotnet ef builds the context without your DI container, so it needs this. Without one it falls back to
booting the whole host just to read a connection string.
The UTC interceptor
Registered for you. It normalizes every DateTimeOffset command parameter to UTC.
MagicDbContext already does that on save, but save only sees entities. A Where comparing a timestamp, an
ExecuteUpdate, an ExecuteDelete and raw SQL all bind parameters without going near the change tracker.
Npgsql requires offset zero for a timestamptz parameter, so one of those carrying a local offset throws at
bind time — on a developer's machine, and not in CI, because CI runs in UTC.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. 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. |
-
net9.0
- MagicCSharp.Data.EntityFramework (>= 1.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.1)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 9.0.4)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on MagicCSharp.Data.Postgres:
| Package | Downloads |
|---|---|
|
MagicCSharp.Testing.Database
Repository integration testing for MagicCSharp against a real PostgreSQL in Testcontainers: one container shared across the suite, a logical database per test class, schema created once, and tables truncated between tests. Separate from MagicCSharp.Testing because it needs Docker, xUnit and Npgsql. |
GitHub repositories
This package is not used by any popular GitHub repositories.