Guide · Agent skill
How to use the EF Core D2 Database Diagram agent skill
Updated · written with AI from the project's own documentation and checked against our catalogue data
The efcore-d2-db-diagram skill lets an AI agent read an Entity Framework Core .NET project and produce a D2 entity-relationship diagram of the database model. It is aimed at .NET developers who want a visual overview of tables, keys and relationships for documentation or onboarding. After this guide you will know what an agent skill is, how to install this one, how to ask for a diagram, and what to check in the output.
Quick start
- 1Download and unzip. Download the skill ZIP from this page and unzip it into ~/.claude/skills/ or your project's .claude/skills/ folder.
- 2Or upload in the Claude apps. In the Claude apps, go to Settings → Capabilities → Skills and upload the ZIP.
- 3Install d2. Install the d2 command-line tool if you want validation and SVG or PNG output.
- 4Ask for a diagram. Describe the diagram you want in plain language and mention EF Core or your DbContext.
- 5Answer the questions. Reply to the display questions or accept the defaults for a quick generation.
- 6Validate and render. Run d2 fmt on the .d2 file and render it with d2 --layout=elk schema.d2 schema.svg.
- 7Review and commit. Check table names, keys and relationships against your code, then commit the .d2 file.
What an agent skill is and what this one does
An agent skill is a folder of instructions and optional scripts that an AI agent loads when a task matches the skill's description. This skill is triggered by requests about Entity Framework Core database diagrams, ERDs, DbContext diagrams and similar topics.
Once installed, the agent reads your DbContext classes, DbSet declarations, Fluent API configurations, entity classes and migrations. It builds a model of the real database schema, including tables, columns, keys, foreign keys, owned types and join tables. It then writes a .d2 text file that draws this as an entity-relationship diagram, and can render it to SVG or PNG with the d2 command-line tool.
- Reads: DbContext, DbSet<T>, OnModelCreating, IEntityTypeConfiguration<T>, entity classes and migrations
- Writes: a .d2 source file you can edit and version with your code
- Renders: SVG or PNG via the d2 CLI, when it is installed
- Asks display questions first, such as which DbContext to diagram and whether to show column types
Install the efcore-d2-db-diagram skill
Download the skill ZIP from this page and unzip it. For a personal install, place the skill folder in ~/.claude/skills/. For a single project, place it in the project's .claude/skills/ folder so it is available only to that project.
In the Claude apps you can instead upload the ZIP under Settings → Capabilities → Skills.
- Personal: unzip into ~/.claude/skills/
- Project only: unzip into your project's .claude/skills/
- Claude apps: Settings → Capabilities → Skills, then upload the ZIP
Install the d2 CLI for rendering
The skill can produce diagram text without the d2 CLI, but validating with d2 fmt and rendering to SVG or PNG requires it. Install d2 from its official distribution before asking for rendered output.
Check that the skill's files are present: SKILL.md plus the references folder with d2-erd-style.md, efcore-model-extraction.md, grouping-modes.md, quality-gate.md and relationship-rules.md.
- Required for rendering and d2 fmt validation
- Not required if you only want the .d2 text
Trigger the skill with natural requests
You do not need special syntax. Describe what you want in plain language and mention EF Core or your DbContext. The skill's description lists phrases such as EF Core database diagram, Entity Framework Core ERD, DbContext diagram and generate .d2 file from EF Core entities.
The agent will then ask its display questions unless you answer them in the same request. You can answer all of them at once, or accept defaults for a quick generation.
- "Generate a D2 database diagram from the EF Core entities in this project."
- "Make an ERD of the DbContext in src/Shop.Data as a .d2 file, show column types, render to SVG."
- "Document the table relationships and join tables in our ASP.NET Core project."
Answer the display questions
The skill asks a fixed set of questions before generating. They cover the DbContext to use, how many columns to show, whether to show types, nullable markers, indexes, enum values, owned types, join tables, technical tables, grouping, layout engine and output format.
If you want a quick result, the defaults are: auto-detect DbContext, key-only columns, column types and nullable markers on, indexes on, enums off, owned types inline, explicit join tables, technical tables off, migration-only tables on, bounded-context grouping, elk layout and d2 output.
- Columns: all, key-only or none
- Owned types: inline, separate or hide
- Join tables: explicit, compact or hide
- Grouping: bounded-context, schema, namespace or flat
- Layout: elk, dagre or tala
- Output: d2, svg or png
Render and check the diagram
The skill validates the file with d2 fmt and, when possible, renders with the ELK layout. You can also run the render command yourself on the generated file.
Technical tables such as __EFMigrationsHistory are hidden by default. If they are hidden, the agent should mention them in its summary after the diagram.
- Validate: d2 fmt schema.d2
- Render: d2 --layout=elk schema.d2 schema.svg
d2 --layout=elk schema.d2 schema.svgSafety notes: scripts and network
This skill runs scripts, so review its contents before you install it, as you would any code you run on your machine. It does not use the network, according to its listing.
The skill is designed to read source files and generate diagram text. It explicitly does not run database migrations or deploy schemas, and it is not for runtime debugging or SQL performance tuning.
- Runs scripts: yes. Review the ZIP contents before installing.
- Uses network: no
- Does not execute migrations or deploy schema changes
- Does not produce draw.io diagrams
Tips for better diagrams
Point the agent at the project that contains the DbContext and migrations, because migrations confirm real table names, join tables, indexes and delete behaviour. The skill's source priority puts the latest migration or model snapshot first when sources disagree.
Commit the generated .d2 file next to your code so the diagram can be edited and reviewed like any other source. When the model changes, ask the agent to regenerate, and it will re-read the mappings and migrations first.
- Include migrations so table names and indexes match the database
- Use key-only columns for a readable overview, and all columns for detailed documentation
- Choose bounded-context grouping for larger schemas and flat for small ones
- Keep the .d2 file under version control
What people use it for
- Onboarding a new developer with a visual map of the database model
- Reviewing primary keys, foreign keys and cardinalities before a schema discussion
- Documenting owned types and many-to-many join tables in an ASP.NET Core project
- Keeping an editable .d2 diagram in the repository alongside the DbContext code
Frequently asked questions
How do I install the efcore-d2-db-diagram skill?
Download the skill ZIP from this page and unzip it into ~/.claude/skills/ for personal use, or into a project's .claude/skills/ folder for one project. In the Claude apps you can upload the ZIP under Settings → Capabilities → Skills.
What do I need to use this skill?
You need access to the EF Core project source files, including DbContext, entities, configurations and migrations. The d2 CLI is needed to validate with d2 fmt and render to SVG or PNG, but the diagram text can be produced without it.
Is the efcore-d2-db-diagram skill free?
The skill is published under the MIT licence in the github/awesome-copilot repository. Check the licence file in the repository for the full terms.
Can this skill run database migrations?
No. The skill reads code and generates diagram text. It is explicitly not for database migration execution, schema deployment, runtime debugging or SQL performance tuning.
Does the skill work with projects that do not use Entity Framework Core?
No. The extraction rules are written for EF Core concepts such as DbContext, DbSet, Fluent API and migrations, so raw SQL projects or other ORMs are outside its scope.
Why does the agent ask so many questions before generating?
The skill requires a set of display choices, such as which DbContext to diagram and whether to show indexes or owned types. You can answer them in your request or accept the listed defaults for a quick run.
Can it draw draw.io diagrams or ERDs for other databases?
It is not for draw.io diagrams. It generates D2 source, and its description also mentions PostgreSQL schema visualization, so check the output against your own database before relying on it.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
Choose this skill if you are a .NET developer who wants an editable D2 diagram of an EF Core model for documentation, onboarding or code review. Pick something else if you need to run migrations, deploy schema, tune SQL, work without EF Core, or produce draw.io diagrams.
Download the skill