/diagram-authoring:efcore-d2-db-diagramfrom diagram-authoring
Generates D2 entity-relationship diagrams from Entity Framework Core models by extracting DbContext, DbSet, entity configuration, migrations, keys, foreign keys, owned types, many-to-many joins, indexes, and schemas.
Ships in diagram-authoring. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Create a readable D2 entity-relationship diagram that reflects the actual EF Core persistence model, not only raw C# class shape. Generate .d2 source and, when possible, validate and render it with the d2 CLI to SVG/PNG. Keep installed package layouts centered on SKILL.md; if documenting installation, mention SKILL.md plus references. SVG/PNG.
d2 CLI when available: d2 input.d2 output.svg, d2 --layout=elk input.d2 output.svg, and d2 fmt input.d2.Ask every question for new diagrams and regenerations. For quick generation, use the defaults.
| Question | Default |
|---|---|
Which DbContext should be diagrammed? (auto-detect/all/specific name) | auto-detect |
Display columns? (all/key-only/none) | key-only |
Display column types? (Yes/No) | Yes |
Display nullable/required markers? (Yes/No) | Yes |
Required/optional relationship notation? (Yes/No) | Yes |
Display indexes and unique constraints? (Yes/No) | Yes |
Display enum values? (Yes/No) | No |
Display owned types? (inline/separate/hide) | inline |
Display many-to-many join tables? (explicit/compact/hide) | explicit |
Display audit/technical tables? (Yes/No) | No |
Audit/technical table summary? (Yes/No) | Yes |
Display migration-only tables not present as entities? (Yes/No) | Yes |
Which grouping mode? (bounded-context/schema/namespace/flat) | bounded-context |
Which layout engine? (elk/dagre/tala) | elk |
Which output format? (d2/svg/png) | d2 |
Use this source priority when sources disagree:
OnModelCreating or IEntityTypeConfiguration<T>.Detect and represent these EF Core concepts:
| Concept | Required extraction |
|---|---|
| Context and entities | DbContext, DbSet<T>, entity class names, actual table names from ToTable, schema names from ToTable("Table", "schema"). |
| Keys | Primary keys from HasKey, [Key], conventions, migrations, composite keys, and HasAlternateKey. |
| Relationships | Foreign keys from HasForeignKey, navigation properties, migration operations, required/optional markers, and delete behavior: Cascade, Restrict, NoAction, SetNull, ClientSetNull. |
| Owned/value objects | OwnsOne, OwnsMany, [Owned], inline/separate/hide rendering choice. |
| Many-to-many | UsingEntity and implicit EF Core join tables; default to explicit join tables. |
| Constraints and columns | HasIndex, IsUnique, shadow properties, value conversions, enum properties, ignored properties, and ignored entities. |
Represent each persisted table as a D2 node with shape: sql_table when possible.
Clients: {
shape: sql_table
constraint: primary_key
Id: uuid {constraint: primary_key}
Name: text
Status: enum
}
If sql_table is unavailable or causes validation issues, use a rectangle with structured text. Draw directional edges from dependent table to principal table, and include cardinality and FK name when known.
Offers.ClientId -> Clients.Id: "N:1 FK_Offers_Clients_ClientId"
Use cardinality labels 1:1, 1:N, N:1, N:N, and owned. Required relationships use solid lines; optional relationships use dashed lines; cascade delete labels end with cascade.
Owned types default to inline rendering:
Clients: {
shape: sql_table
Id: uuid {constraint: primary_key}
Address.Street: text
Address.ZipCode: text
Address.City: text
}
When the user chooses separate, represent owned types as visually subordinate tables and use an owned relationship. For implicit many-to-many relationships, create a generated join table node and mark it as implicit join.
| Mode | Rule |
|---|---|
bounded-context | Group by detected domain area or folder/module. |
schema | Group by database schema such as public, auth, or billing. |
namespace | Group by C# namespace. |
flat | Use no containers; all tables at the same level. |
| Element | Style |
|---|---|
| Primary entity tables | Solid border. |
| Join tables | Dashed border. |
| Owned types | Lighter stroke or nested inline fields. |
| Technical tables | Muted style. |
| External or migration-only tables | Dotted border. |
Hide technical tables by default unless requested. Examples include __EFMigrationsHistory, Hangfire tables, ASP.NET Identity tables, audit logs, and outbox tables. If hidden, list them in the summary.
DbContext classes.DbSet<T> declarations.OnModelCreating and all IEntityTypeConfiguration<T> classes..d2 file from the database model, not raw class nesting.d2 fmt before delivery.d2 --layout=elk schema.d2 schema.svg when possible.Load bundled references on demand:
references/efcore-model-extraction.md: rules for reading DbContext, DbSet, Fluent API, configurations, and migrations.references/d2-erd-style.md: D2 syntax and visual conventions for ERD diagrams.references/relationship-rules.md: how to infer one-to-one, one-to-many, many-to-many, and owned relationships.references/grouping-modes.md: rules for bounded-context, schema, namespace, and flat grouping.references/quality-gate.md: final checklist before delivering the generated diagram.## EF Core D2 diagram — <DbContext or scope>
**Status:** generated | needs answers | blocked
**Selected DbContext:** <auto-detect/all/name>
**Output format:** d2 | svg | png
**Layout:** elk | dagre | tala
### D2 source
```d2
<schema.d2 content>
```
### Render command
```bash
d2 --layout=elk schema.d2 schema.svg
```
### Assumptions and hidden tables
- Columns: all | key-only | none
- Owned types: inline | separate | hide
- Many-to-many join tables: explicit | compact | hide
- Hidden technical tables: `__EFMigrationsHistory`, <others or none>
### Validation
- `d2 fmt schema.d2`: pass | fail | not run
- EF Core mappings read: migrations, Fluent API, annotations, conventions
DbContext is clear.DbSet<T> entities are considered.OnModelCreating and IEntityTypeConfiguration<T> are read.inline, separate, or hide choice.d2 fmt when the CLI is available.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
ef-core, entity-framework, d2-diagram, erd, database-diagram, dotnet
npx claudepluginhub gbb-acelerators/awesome-harness-primitives --plugin diagram-authoring4 skills in this plugin
/draw-io-diagram-generatorUse when creating, editing, or generating draw.io diagram files (.drawio, .drawio.svg, .drawio.png). Covers mxGraph XML authoring, shape libraries, style strings, flowcharts, system architecture, sequence diagrams, ER diagrams, UML class diagrams, network topology, layout strategy, the hediet.vscode-drawio VS Code extension, and the full agent workflow from request to a ready-to-open file./excalidraw-diagram-generatorGenerate valid .excalidraw JSON diagrams from natural language descriptions, including flowcharts, relationship diagrams, mind maps, architecture diagrams, DFDs, swimlanes, class diagrams, sequence diagrams, and ER diagrams. Use when asked to create a diagram, make a flowchart, visualize a process, draw a system architecture, create a mind map, show relationships, or generate an Excalidraw file./plantuml-asciiGenerate ASCII art diagrams using PlantUML text mode. Use when user asks to create ASCII diagrams, text-based diagrams, terminal-friendly diagrams, or mentions plantuml ascii, text diagram, ascii art diagram. Supports: Converting PlantUML diagrams to ASCII art, Creating sequence diagrams, class diagrams, flowcharts in ASCII format, Generating Unicode-enhanced ASCII art with -utxt flagOther plugins' skills for the same job