SyntaxCircus.EntityFrameworkCore.Postgres 0.1.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package SyntaxCircus.EntityFrameworkCore.Postgres --version 0.1.2
                    
NuGet\Install-Package SyntaxCircus.EntityFrameworkCore.Postgres -Version 0.1.2
                    
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.2" />
                    
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.2" />
                    
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.2
                    
#r "nuget: SyntaxCircus.EntityFrameworkCore.Postgres, 0.1.2"
                    
#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.2
                    
#: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.2
                    
Install as a Cake Addin
#tool nuget:?package=SyntaxCircus.EntityFrameworkCore.Postgres&version=0.1.2
                    
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, so its UseSnakeCaseNamingConvention() is available with no separate install:

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

EFCore.NamingConventions also ships camelCase, lower_case, and other convention variants — see its own docs for the full list.

Snake_case migrations history table

If you've also opted into UseSnakeCaseNamingConvention() above and want the migrations-history table itself (__ef_migrations_history, migration_id, product_version) renamed to match:

optionsBuilder.UseNpgsql(connectionString)
    .UseSnakeCaseNamingConvention()
    .ReplaceService<IHistoryRepository, SnakeCaseHistoryRepository>();

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 561 8/17/2026
0.1.2 98 8/17/2026
0.1.1 105 8/16/2026