QuickPersistr.EntityFrameworkCore.PostgreSql
0.0.2
dotnet add package QuickPersistr.EntityFrameworkCore.PostgreSql --version 0.0.2
NuGet\Install-Package QuickPersistr.EntityFrameworkCore.PostgreSql -Version 0.0.2
<PackageReference Include="QuickPersistr.EntityFrameworkCore.PostgreSql" Version="0.0.2" />
<PackageVersion Include="QuickPersistr.EntityFrameworkCore.PostgreSql" Version="0.0.2" />
<PackageReference Include="QuickPersistr.EntityFrameworkCore.PostgreSql" />
paket add QuickPersistr.EntityFrameworkCore.PostgreSql --version 0.0.2
#r "nuget: QuickPersistr.EntityFrameworkCore.PostgreSql, 0.0.2"
#:package QuickPersistr.EntityFrameworkCore.PostgreSql@0.0.2
#addin nuget:?package=QuickPersistr.EntityFrameworkCore.PostgreSql&version=0.0.2
#tool nuget:?package=QuickPersistr.EntityFrameworkCore.PostgreSql&version=0.0.2
QuickPersistr.EntityFrameworkCore.PostgreSql
An isolated PostgreSQL database scope for QuickPersistr and Entity Framework Core, powered by Npgsql.
dotnet add package QuickPersistr.EntityFrameworkCore.PostgreSql --version 0.0.1
Use a dedicated PostgreSQL test server. The supplied user must be allowed to create, terminate connections to, and drop databases. Never supply production credentials.
Usage
using QuickPersistr;
using QuickPersistr.EntityFrameworkCore.PostgreSql;
var serverConnectionString =
Environment.GetEnvironmentVariable("QUICKPERSISTR_POSTGRES")
?? throw new InvalidOperationException(
"Set QUICKPERSISTR_POSTGRES to a dedicated PostgreSQL test server.");
Persistr.Named("Books on PostgreSQL")
.Scope(() => new PostgreSqlPersistenceScope<LibraryDbContext>(
serverConnectionString,
options => new LibraryDbContext(options)))
.Entities(new BookPersistence())
.Run();
The connection string identifies the server and maintenance database used to issue CREATE DATABASE and DROP DATABASE. If it omits the database, postgres is used.
Database lifecycle
For every scope, the adapter:
- creates a uniquely named database such as
quickpersistr_<guid>; - builds the schema with
Database.EnsureCreated(); - opens fresh contexts against that database for session and concurrency checks;
- terminates remaining connections and drops only that generated database on disposal.
Generated database connections have pooling disabled so cleanup is deterministic. Different scopes use different names and can run in parallel. If a test process is killed before disposal, a generated database may remain; it can be identified by the quickpersistr_ prefix. A custom prefix may contain at most 30 ASCII letters, digits, or underscores.
If containers, migrations, or another fixture already manage database lifetime, use QuickPersistr.EntityFrameworkCore.EfPersistenceScope<TDbContext> instead.
This package supports EF Core 8.x and Npgsql 8.x, and targets .NET 8. QuickPersistr is an early preview. APIs may change before version 1.0.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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. |
-
net8.0
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 8.0.10 && < 9.0.0)
- QuickPersistr.EntityFrameworkCore (>= 0.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.