This sample demonstrates using JD.Efcpt.Build with connection string mode to reverse engineer Entity Framework Core models directly from a SQLite database file.
- Connection String Mode: No DACPAC or SQL project required
- SQLite Provider: Using
Microsoft.Data.Sqlitefor schema reading - Automatic Schema Fingerprinting: Detects schema changes and regenerates only when needed
- T4 Templates: Customizable code generation
connection-string-sqlite/
├── Database/
│ └── sample.db # SQLite database file (created by setup script)
├── EntityFrameworkCoreProject/
│ ├── EntityFrameworkCoreProject.csproj
│ ├── efcpt-config.json
│ └── efcpt.renaming.json
├── setup-database.ps1 # Creates the sample database
└── README.md
- .NET 10.0 SDK or later
- PowerShell (for setup script)
Run the setup script to create a SQLite database with sample tables:
./setup-database.ps1This creates Database/sample.db with the following schema:
categories- Product categoriesproducts- Products with category referencesorders- Customer ordersorder_items- Order line items
dotnet build EntityFrameworkCoreProjectDuring build, JD.Efcpt.Build will:
- Connect to the SQLite database using the connection string
- Read the schema metadata
- Generate Entity Framework Core models and DbContext
- Output files to the
Models/directory
After building, check EntityFrameworkCoreProject/Models/ for:
SampleDbContext.cs- The DbContext- Entity classes for each table
The .csproj file configures connection string mode:
<!-- Use connection string mode instead of DACPAC -->
<EfcptConnectionString>Data Source=$(MSBuildProjectDirectory)\..\Database\sample.db</EfcptConnectionString>
<EfcptProvider>sqlite</EfcptProvider>| Provider | Value | Description |
|---|---|---|
| SQL Server | mssql |
Microsoft SQL Server |
| PostgreSQL | postgres |
PostgreSQL / CockroachDB |
| MySQL | mysql |
MySQL / MariaDB |
| SQLite | sqlite |
SQLite database files |
| Oracle | oracle |
Oracle Database |
| Firebird | firebird |
Firebird SQL |
| Snowflake | snowflake |
Snowflake Data Cloud |
When you modify the database schema:
- The fingerprint will detect the change
- Next build will regenerate the models
- Previous fingerprint is stored in
obj/efcpt/.fingerprint
To force regeneration:
dotnet clean EntityFrameworkCoreProject
dotnet build EntityFrameworkCoreProjectEnsure you've run setup-database.ps1 first to create the sample database.
Delete the fingerprint file to force regeneration:
rm EntityFrameworkCoreProject/obj/efcpt/.fingerprint