SyntaxCircus.EntityFrameworkCore.Postgres 0.1.3

dotnet add package SyntaxCircus.EntityFrameworkCore.Postgres --version 0.1.3
                    
NuGet\Install-Package SyntaxCircus.EntityFrameworkCore.Postgres -Version 0.1.3
                    
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="SyntaxCircus.EntityFrameworkCore.Postgres" Version="0.1.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SyntaxCircus.EntityFrameworkCore.Postgres" Version="0.1.3" />
                    
Directory.Packages.props
<PackageReference Include="SyntaxCircus.EntityFrameworkCore.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 SyntaxCircus.EntityFrameworkCore.Postgres --version 0.1.3
                    
#r "nuget: SyntaxCircus.EntityFrameworkCore.Postgres, 0.1.3"
                    
#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 SyntaxCircus.EntityFrameworkCore.Postgres@0.1.3
                    
#: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=SyntaxCircus.EntityFrameworkCore.Postgres&version=0.1.3
                    
Install as a Cake Addin
#tool nuget:?package=SyntaxCircus.EntityFrameworkCore.Postgres&version=0.1.3
                    
Install as a Cake Tool

SyntaxCircus.EntityFrameworkCore.Postgres

Build NuGet License: MIT

An auditable-entity base with a TimeProvider-driven SaveChanges interceptor, a Postgres advisory-lock-guarded migrate-on-startup helper, snake_case entity/column naming, and a snake_case migrations-history repository — for products on EF Core + Npgsql.

No support guaranteed. Published as-is and maintained on a best-effort basis. Issues and PRs are welcome, but there's no SLA — fork it or vendor what you need if that's not enough.

Auditable entities

public sealed class Widget : AuditableEntity
{
    public string Name { get; set; } = string.Empty;
}

optionsBuilder.UseNpgsql(connectionString);
optionsBuilder.AddTrackableEntityInterceptor(); // stamps CreatedAt/UpdatedAt on save

AuditableEntity gives you Id, CreatedAt, UpdatedAt. If you already have a base entity, just implement ITrackableEntity (CreatedAt/UpdatedAt) instead — the interceptor works off the interface, not the base class. AddTrackableEntityInterceptor(timeProvider) takes an optional TimeProvider for testability; defaults to TimeProvider.System.

Migrate on startup, safely

await using var scope = app.Services.CreateAsyncScope();
var context = scope.ServiceProvider.GetRequiredService<MyDbContext>();
await context.MigrateWithAdvisoryLockAsync(lockKey: 823_471); // any consistent int64 for this DbContext

Takes a Postgres advisory lock before calling Database.MigrateAsync(), so multiple instances of the same service starting up concurrently don't race to apply migrations. Falls back to a plain, lock-free migrate for non-Postgres providers.

Snake_case entity and column naming

This package depends on EFCore.NamingConventions and wraps its UseSnakeCaseNamingConvention():

optionsBuilder.UseNpgsql(connectionString)
    .UseSyntaxCircusSnakeCaseNamingConvention(); // entity and column names become snake_case, e.g. CreatedAt -> created_at

Use UseSyntaxCircusSnakeCaseNamingConvention(), not the raw UseSnakeCaseNamingConvention() from EFCore.NamingConventions directly - a naming-convention plugin applies to every model built from the context's convention pipeline, including the internal model EF Core uses for its own __EFMigrationsHistory migrations-history table. Calling the raw method alone silently renames that framework-owned table's columns as an unadvertised side effect (confirmed: it isn't a consumer-owned entity, so this is unintended - see docs/enhancements/2026-08-17-missing-snake-case-naming-convention.md). UseSyntaxCircusSnakeCaseNamingConvention() snake-cases your own entities the same way, while automatically keeping the migrations-history table in its EF Core framework-default naming (__EFMigrationsHistory / MigrationId / ProductVersion) unless you opt into renaming it too (below).

EFCore.NamingConventions also ships camelCase, lower_case, and other convention variants — call its own UseSnakeCaseNamingConvention()/etc. directly if you want one of those without this package's migrations-history protection.

Snake_case migrations history table

If you've opted into UseSyntaxCircusSnakeCaseNamingConvention() above and do want the migrations-history table itself (__ef_migrations_history, migration_id, product_version) renamed to match — note this requires a one-time manual column rename on any database that already has migrations applied under the old naming, since EF has to read that table to know which migrations are applied before it can run one that would rename it:

optionsBuilder.UseNpgsql(connectionString)
    .UseSyntaxCircusSnakeCaseNamingConvention()
    .ReplaceService<IHistoryRepository, SnakeCaseHistoryRepository>(); // registered after, so it wins

Contributing

Issues and pull requests are welcome:

  • Keep changes focused, with a clear description of the behavior change.
  • Match the existing code style (see .editorconfig).
  • Call out any breaking changes to the public API in your PR description.

License

MIT — see LICENSE.txt.

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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.3 544 8/17/2026
0.1.2 98 8/17/2026
0.1.1 105 8/16/2026