Mermaid-Only Generation
Generates a Mermaid ER diagram from your schema (DACPAC, .sqlproj, or live connection) without producing any DbContext or entity .g.cs files. Closes the feature request in #246.
What it does
The regular JD.Efcpt.Build pipeline runs the upstream efcpt CLI with generate-mermaid-diagram=true set in efcpt-config.json, which emits a .md Mermaid file alongside the DbContext and entity .g.cs files. There is no flag in the upstream schema to skip the C# files, so a .g.cs set always comes with the .md.
EfcptMermaidOnly reuses the same pipeline but adds three extra steps:
_EfcptApplyMermaidOnlyOverridesruns beforeEfcptApplyConfigOverridesand forces the staged JSON config to setgenerate-mermaid-diagram=trueandtype=dbcontext(soefcptwrites only the DbContext.g.csplus the.md).EfcptGenerateMermaidruns afterEfcptComputeFingerprintand invokesefcptwith the same arguments asEfcptGenerateModels.- The same target moves the
.mdinto$(EfcptMermaidOutputDir)and deletes the leftover.g.csfiles.EfcptAddToCompileis skipped, so nothing reaches the host project'sCompilelist.
Net result: a .md Mermaid file in obj/efcpt/Generated/Mermaid/, no .g.cs files compiled into the host assembly.
Usage
From the command line (one-off, no project changes)
dotnet build -t:EfcptGenerateMermaid
This runs the Mermaid target in isolation. It still needs a DACPAC, .sqlproj, or connection string the same way a regular build does.
As part of every build
<PropertyGroup>
<EfcptMermaidOnly>true</EfcptMermaidOnly>
<EfcptMermaidOutputDir>$(MSBuildProjectDirectory)\docs\db\</EfcptMermaidOutputDir>
</PropertyGroup>
The diagram is rewritten on every build that touches the schema. It is committed to source control alongside the rest of the docs.
Properties
| Property | Default | Description |
|---|---|---|
EfcptMermaidOnly |
false |
When true, the regular DbContext/entity generation is replaced with EfcptGenerateMermaid. |
EfcptMermaidOutputDir |
$(EfcptGeneratedDir)Mermaid\ |
Where the .md Mermaid file lands after the leftover .g.cs files are deleted. |
Both are also documented in Configuration.
Caveats
EfcptMermaidOnlyonly affects the EF Core consumer side of a mixed setup. A pure.sqlprojconsuming project never invokesefcpt, so the flag is a no-op there.- The diagram is generated by the same incremental / fingerprint gate as
EfcptGenerateModels. PassEfcptForceRegenerate=trueif you need to regenerate without changing the schema. - The leftover
.g.csfile is written and then deleted on disk. If you pointEfcptLogVerbosity=detailedandEfcptDumpResolvedInputs=true, you'll seeefcptproduce and then have its output cleaned up; this is by design until upstreamefcptgains a true diagram-only value.