MagicCSharp.Data.Postgres 1.0.0

There is a newer version of this package available.
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
                    
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="MagicCSharp.Data.Postgres" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MagicCSharp.Data.Postgres" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="MagicCSharp.Data.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 MagicCSharp.Data.Postgres --version 1.0.0
                    
#r "nuget: MagicCSharp.Data.Postgres, 1.0.0"
                    
#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 MagicCSharp.Data.Postgres@1.0.0
                    
#: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=MagicCSharp.Data.Postgres&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=MagicCSharp.Data.Postgres&version=1.0.0
                    
Install as a Cake Tool

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 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. 
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 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.

Version Downloads Last Updated
1.0.2 245 9/24/2026
1.0.1 105 9/24/2026
1.0.0 100 9/23/2026