Table of Contents

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:

  1. _EfcptApplyMermaidOnlyOverrides runs before EfcptApplyConfigOverrides and forces the staged JSON config to set generate-mermaid-diagram=true and type=dbcontext (so efcpt writes only the DbContext .g.cs plus the .md).
  2. EfcptGenerateMermaid runs after EfcptComputeFingerprint and invokes efcpt with the same arguments as EfcptGenerateModels.
  3. The same target moves the .md into $(EfcptMermaidOutputDir) and deletes the leftover .g.cs files. EfcptAddToCompile is skipped, so nothing reaches the host project's Compile list.

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

  • EfcptMermaidOnly only affects the EF Core consumer side of a mixed setup. A pure .sqlproj consuming project never invokes efcpt, so the flag is a no-op there.
  • The diagram is generated by the same incremental / fingerprint gate as EfcptGenerateModels. Pass EfcptForceRegenerate=true if you need to regenerate without changing the schema.
  • The leftover .g.cs file is written and then deleted on disk. If you point EfcptLogVerbosity=detailed and EfcptDumpResolvedInputs=true, you'll see efcpt produce and then have its output cleaned up; this is by design until upstream efcpt gains a true diagram-only value.