Rask.Postgres 0.23.1-alpha.0.62

This is a prerelease version of Rask.Postgres.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Rask.Postgres --version 0.23.1-alpha.0.62
                    
NuGet\Install-Package Rask.Postgres -Version 0.23.1-alpha.0.62
                    
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="Rask.Postgres" Version="0.23.1-alpha.0.62" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Rask.Postgres" Version="0.23.1-alpha.0.62" />
                    
Directory.Packages.props
<PackageReference Include="Rask.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 Rask.Postgres --version 0.23.1-alpha.0.62
                    
#r "nuget: Rask.Postgres, 0.23.1-alpha.0.62"
                    
#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 Rask.Postgres@0.23.1-alpha.0.62
                    
#: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=Rask.Postgres&version=0.23.1-alpha.0.62&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Rask.Postgres&version=0.23.1-alpha.0.62&prerelease
                    
Install as a Cake Tool

Rask.Postgres

PostgreSQL for .NET apps on Entity Framework Core. UseRaskPostgres(...) is a drop-in replacement for UseNpgsql that gives every session the production timeouts — statement_timeout, lock_timeout, idle_in_transaction_session_timeout — and turns on Npgsql's transient-failure retrying.

SQLite remains Rask's default, and for most single-developer products it is the right answer for a long time. This package is the door out of one box: a managed database, a read replica, or more app instances than one file can serve.

Install

dotnet add package Rask.Postgres

Use

builder.Services.AddDbContextFactory<AppDbContext>((sp, o) => o
    .UseRaskPostgres(sp)
    .AddInterceptors(sp.GetServices<ISaveChangesInterceptor>()));

The connection string is Rask:ConnectionStrings:App in configuration — in production usually the whole string, password included, as Rask__ConnectionStrings__App in the environment — and a missing one is an error naming that key.

Override any default in the Rask:Postgres section:

{ "Rask": { "Postgres": { "StatementTimeout": "00:00:10", "LockTimeout": "00:00:03", "Retry": { "MaxCount": 3 } } } }

or through the optional configure delegate, which runs after the section and wins:

o.UseRaskPostgres(sp, p =>
{
    p.StatementTimeout = 10.Seconds;
    p.LockTimeout = 3.Seconds;
    p.Retry.MaxCount = 3;
});

HasFullTextSearch, Search(text), FullText.Highlight and FullText.Snippet from Rask.Data work here as they do on SQLite:

builder.HasFullTextSearch(p => new { p.Title, p.Body });                 // in the entity's configuration

var hits = await db.Posts.Search("postgres sqli")                         // every word, the last as a prefix
    .Select(p => new { p.Id, Title = FullText.Highlight(p.Title) })       // matches marked for Ui.Highlight
    .ToListAsync();                                                       // best match first

The index is a stored generated tsvector column with a GIN index, created by your migration and kept current by PostgreSQL itself. FullTextTokenizer.Unicode folds accents (keres finds kérés) through a rask_unicode text search configuration built on unaccent, which the first migration that needs it creates.

What the defaults do

Setting Default Why
StatementTimeout 30s A runaway query otherwise runs until the client disconnects.
LockTimeout 10s The analogue of SQLite's busy_timeout. Without it, a statement stuck behind a lock reports as a slow query, which sends you debugging the wrong thing. Must be below StatementTimeout.
IdleInTransactionSessionTimeout 1m An idle-in-transaction session keeps its locks and blocks VACUUM from reclaiming dead rows — the usual way a healthy database quietly bloats.
Retry.Enabled / MaxCount / MaxDelay on / 6 / 30s Npgsql's own EnableRetryOnFailure, which already knows which PostgreSQL error codes are transient.

Set a timeout to TimeSpan.Zero to leave it to the server, so a server-level or role-level setting wins instead of being overwritten.

The timeouts travel as startup parameters in the connection string (Options=-c statement_timeout=…), so they are the session's defaults: they survive the pool resetting a returned connection, cost no round trip per query, and reach code that opens the DbConnection itself. A -c your connection string already carries wins. Behind PgBouncer in transaction mode, add options to its ignore_startup_parameters, or set the timeouts to TimeSpan.Zero and configure them on the database role.

Retrying is an execution strategy, and like every EF Core retrying strategy it refuses a transaction you opened yourself outside it: wrap a hand-written BeginTransaction in context.Database.CreateExecutionStrategy().ExecuteAsync(...), or set Rask:Postgres:Retry:Enabled to false. SaveChanges, and Rask's jobs, mail, outbox and cache, need nothing.

What stays behind

Litestream continuous backup and file snapshots (Rask.SQLite.Litestream, Rask.SQLite.Snapshots) are SQLite-only by definition — they replicate and copy a file. On PostgreSQL, backup is your provider's snapshots or pg_dump. Migrations are unchanged: dotnet ef (and rask db) are provider-agnostic.

Full documentation: https://github.com/pal-tamas/rask/blob/main/docs/data.md#postgresql

Product 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.  net11.0 is compatible. 
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 Rask.Postgres:

Package Downloads
Rask.Server

The ASP.NET host for Rask, a full-stack .NET web framework, with every battery: database (SQLite, PostgreSQL or SQL Server, picked by Rask:Database:Provider), mediator and query cache, accounts, background jobs, transactional email, cache, file storage, outbox, operator dashboard, durable logs, Web Push, SQLite snapshots and continuous backup. Renders Rask components with live updates over a WebSocket. RaskApp.Create(args).Run<App>() is the whole Program.cs; app.Configure(c => c.Jobs.Off()) is how an app does without one. Depends on Rask, the shared core.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.23.1-alpha.0.84 0 9/25/2026
0.23.1-alpha.0.81 0 9/25/2026
0.23.1-alpha.0.80 0 9/25/2026
0.23.1-alpha.0.79 0 9/25/2026
0.23.1-alpha.0.78 0 9/25/2026
0.23.1-alpha.0.76 0 9/25/2026
0.23.1-alpha.0.74 0 9/25/2026
0.23.1-alpha.0.72 0 9/25/2026
0.23.1-alpha.0.70 0 9/25/2026
0.23.1-alpha.0.69 0 9/25/2026
0.23.1-alpha.0.68 0 9/25/2026
0.23.1-alpha.0.67 0 9/25/2026
0.23.1-alpha.0.66 21 9/24/2026
0.23.1-alpha.0.65 26 9/24/2026
0.23.1-alpha.0.64 20 9/24/2026
0.23.1-alpha.0.62 26 9/24/2026
0.23.1-alpha.0.61 28 9/24/2026
0.23.1-alpha.0.50 28 9/24/2026
0.23.1-alpha.0.49 26 9/24/2026
0.23.0 94 9/18/2026
Loading failed