This sample demonstrates configuring JD.Efcpt.Build for PostgreSQL using Connection
String Mode, and shows the shape of the EF Core models efcpt generates for a Postgres schema.
EfcptProvider=postgresconfiguration- The
Npgsql.EntityFrameworkCore.PostgreSQLruntime provider wired up inAppDbContext - A minimal
efcpt-config.jsonfor connection-string-mode generation - How to keep a sample buildable in CI without a live database by committing a reference copy of the generated code (see Committed Generated Code below)
provider-postgres/
├── ProviderPostgres.sln
├── nuget.config
└── EntityFrameworkCoreProject/
├── EntityFrameworkCoreProject.csproj
├── efcpt-config.json
└── Generated/ # Committed reference copy (see below)
├── AppDbContext.cs
└── Entities/
├── Customer.cs
└── Order.cs
Host=localhost;Database=mydb;Username=user;Password=pwd;Port=5432
PostgreSQL has no DACPAC equivalent, so real generation requires a live database:
- Install the PostgreSQL driver satellite package (only needed while regenerating, JD.Efcpt.Build
itself is already referenced):
dotnet add EntityFrameworkCoreProject package JD.Efcpt.Build.PostgreSQL
- Point at a real database and build:
(
set EfcptConnectionString=Host=localhost;Database=mydb;Username=user;Password=pwd dotnet build EntityFrameworkCoreProject
export EfcptConnectionString=...on macOS/Linux.)
With EfcptConnectionString set, EfcptEnabled turns on automatically (see the csproj), efcpt
regenerates real models into obj/efcpt/Generated, and the committed Generated/ reference copy
in the project directory is excluded from compilation for that build so the two don't collide.
Without a connection string (as in CI), EfcptEnabled is forced to false, which fully
short-circuits generation - no DB connection, DACPAC query, or efcpt invocation happens. Instead
the project compiles the committed Generated/AppDbContext.cs and Generated/Entities/*.cs
files, which are hand-written to mirror realistic efcpt output for a customers/orders
schema. This is what lets dotnet build EntityFrameworkCoreProject -p:EfcptEnabled=false succeed
in CI with zero database dependency - see the samples-build job in .github/workflows/ci.yml.
dotnet build ProviderPostgres.sln