Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds automatic Mermaid ER diagram generation as part of the SQL project build process. It extracts table, column, primary key, and foreign key metadata from the DacFX model and produces a .md file containing a Mermaid erDiagram block.
Changes:
- New
Diagram/module in DacpacTool with model classes, DacFX-to-model extraction, and Mermaid rendering - New
--gedCLI option and MSBuild propertyGenerateErDiagram(enabled by default) to trigger diagram generation - Test coverage for the diagram builder
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/DacpacTool/Diagram/DatabaseModelToMermaid.cs | Converts simplified table model to Mermaid ER diagram syntax |
| src/DacpacTool/Diagram/DacpacModelFactory.cs | Extracts tables/columns/keys from TSqlModel into simple model classes |
| src/DacpacTool/Diagram/MermaidDiagramBuilder.cs | Orchestrates diagram generation and file output |
| src/DacpacTool/Diagram/Model/*.cs | Simple POCO model classes for tables, columns, keys |
| src/DacpacTool/BuildOptions.cs | Adds GenerateErDiagram CLI option |
| src/DacpacTool/Program.cs | Calls diagram builder when option is set |
| src/DacpacTool/DacpacTool.csproj | Bumps LangVersion to 12.0 |
| src/MSBuild.Sdk.SqlProj/Sdk/Sdk.props | Adds GenerateErDiagram default property (true) |
| src/MSBuild.Sdk.SqlProj/Sdk/Sdk.targets | Passes --ged flag and copies .md artifacts |
| test/DacpacTool.Tests/DiagramBuilderTests.cs | Test for basic diagram generation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
@ErikEJ This is off to a great start I think, just a couple of comments. Also, do we have an example of what the output looks like? |
|
@jmezach Re "example" do you mean the rendered graphic? I can add one a link to it from the missing new readme section perhaps? |
|
@ErikEJ Yeah, it was really just to satisfy my curiosity I guess ;). But I think it would be useful to have an example graphic in our README so that folks know what the feature would do |
|
@ErikEJ Yeah I think a slightly smaller one would be useful to have in the README. Perhaps we can just generate one from our test projects and stick that into the README? |
There was a problem hiding this comment.
Pull request overview
Adds optional ER diagram generation (Mermaid markdown) to the SQLProj build pipeline, exposing it via an MSBuild property / CLI flag and surfacing it in the project template + documentation.
Changes:
- Add
GenerateErDiagramMSBuild property support that forwards a new--gedflag toDacpacTooland copies generated*_erdiagram.mdto the output directory. - Implement ER diagram generation in
DacpacToolby extracting tables/PKs/FKs from the DacFx model and emitting Mermaid ER markdown. - Add template option + README documentation and a unit test for diagram generation.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| test/TestProject/TestProject.csproj | Enables ER diagram generation in the test project. |
| test/DacpacTool.Tests/DiagramBuilderTests.cs | Adds a unit test validating Mermaid ER output and filtering out non-table objects. |
| src/MSBuild.Sdk.SqlProj/Sdk/Sdk.targets | Adds build argument (--ged) and copies *_erdiagram.md artifacts to output. |
| src/MSBuild.Sdk.SqlProj.Templates/templates/sqlproj/sqlproj.csproj | Adds GenerateErDiagram property placeholder to the template. |
| src/MSBuild.Sdk.SqlProj.Templates/templates/sqlproj/.template.config/template.json | Adds erDiagram boolean template parameter. |
| src/DacpacTool/Program.cs | Invokes ER diagram generation during build when enabled. |
| src/DacpacTool/Diagram/Model/Simple*.cs | Introduces simplified table/column/key model for diagram generation. |
| src/DacpacTool/Diagram/MermaidDiagramBuilder.cs | Writes the ER diagram markdown file next to the built dacpac. |
| src/DacpacTool/Diagram/DatabaseModelToMermaid.cs | Converts simplified model to Mermaid ER diagram text. |
| src/DacpacTool/Diagram/DacpacModelFactory.cs | Extracts tables/columns/PK/FK info from TSqlModel. |
| src/DacpacTool/DacpacTool.csproj | Bumps C# language version to support new syntax used by diagram code. |
| src/DacpacTool/BuildOptions.cs | Adds --generateerdiagram / --ged CLI option. |
| README.md | Documents enabling and output of ER diagram generation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
Adds an optional build-time feature to generate a Mermaid ER diagram from the built dacpac, exposing it via MSBuild + CLI, surfacing it in the project template, and documenting the new capability.
Changes:
- Add
GenerateErDiagramMSBuild property and pass through to DacpacTool build via a new CLI switch. - Implement ER diagram generation by enumerating the DacFx model (tables/PK/FK/columns) and writing a
*_erdiagram.mdMermaid file. - Add template + documentation updates and a basic unit test for diagram generation.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| test/TestProject/TestProject.csproj | Enables ER diagram generation in the test project. |
| test/DacpacTool.Tests/DiagramBuilderTests.cs | Adds a unit test validating basic Mermaid output. |
| src/MSBuild.Sdk.SqlProj/Sdk/Sdk.targets | Adds the build argument and copies generated *_erdiagram.md artifacts to output. |
| src/MSBuild.Sdk.SqlProj.Templates/templates/sqlproj/sqlproj.csproj | Exposes GenerateErDiagram in the project template. |
| src/MSBuild.Sdk.SqlProj.Templates/templates/sqlproj/.template.config/template.json | Adds a template parameter to toggle ER diagram generation. |
| src/DacpacTool/Program.cs | Invokes ER diagram generation during build when enabled. |
| src/DacpacTool/BuildOptions.cs | Adds the --generateerdiagram option (with alias). |
| src/DacpacTool/DacpacTool.csproj | Bumps C# language version to support new syntax used by diagram model types. |
| src/DacpacTool/Diagram/Model/SimpleTable.cs | Adds a simplified table model for diagram generation. |
| src/DacpacTool/Diagram/Model/SimplePrimaryKey.cs | Adds a simplified PK model. |
| src/DacpacTool/Diagram/Model/SimpleForeignKey.cs | Adds a simplified FK model. |
| src/DacpacTool/Diagram/Model/SimpleColumn.cs | Adds a simplified column model. |
| src/DacpacTool/Diagram/MermaidDiagramBuilder.cs | Adds ErDiagramBuilder to generate and write the Mermaid markdown file. |
| src/DacpacTool/Diagram/DatabaseModelToMermaid.cs | Renders the simplified database model to Mermaid ER syntax. |
| src/DacpacTool/Diagram/DacpacModelFactory.cs | Extracts tables/columns/PK/FK/type info from the DacFx TSqlModel. |
| README.md | Documents the new ER diagram feature and how to enable it. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
jmezach
left a comment
There was a problem hiding this comment.
LGTM. I think it makes sense to ship this as a 4.1 release. Just some merge conflicts to resolve now though ;).
|
There might be an issue with duplicate table names across schemas. I created a PR on your fork: ErikEJ#157 |
|
@jeffrosenberg Can you have a look at this? I think this is good to merge. |
|
@jmezach Merge conflict fixed now |
There was a problem hiding this comment.
Pull request overview
Adds optional build-time generation of a Mermaid ER diagram from the produced dacpac (via DacFx model enumeration), and surfaces the option in templates and docs.
Changes:
- Adds
GenerateEntityRelationshipDiagramMSBuild property, wiring it to a new-ged/--generateerdiagramoption inDacpacTool build. - Introduces diagram generation implementation (model extraction + Mermaid rendering) and a unit test covering basic output.
- Updates template + README to expose and document the feature, and copies the generated
*_erdiagram.mdinto the build output.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| test/TestProject/TestProject.csproj | Enables ER diagram generation in test project properties. |
| test/TestProject/TestProject_erdiagram.md | Adds an example generated Mermaid markdown diagram artifact. |
| test/DacpacTool.Tests/DiagramBuilderTests.cs | Adds unit test validating diagram generation output content. |
| src/MSBuild.Sdk.SqlProj/Sdk/Sdk.targets | Adds -ged argument wiring and copies diagram artifacts to $(TargetDir). |
| src/MSBuild.Sdk.SqlProj.Templates/templates/sqlproj/sqlproj.csproj | Adds template property placeholder for ER diagram generation. |
| src/MSBuild.Sdk.SqlProj.Templates/templates/sqlproj/.template.config/template.json | Adds a boolean template parameter to toggle ER diagram generation. |
| src/DacpacTool/Program.cs | Invokes diagram generation after successful build when enabled. |
| src/DacpacTool/Diagram/Model/SimpleTable.cs | Introduces simplified table model for diagram generation. |
| src/DacpacTool/Diagram/Model/SimplePrimaryKey.cs | Introduces simplified PK model for diagram generation. |
| src/DacpacTool/Diagram/Model/SimpleForeignKey.cs | Introduces simplified FK model for diagram generation. |
| src/DacpacTool/Diagram/Model/SimpleColumn.cs | Introduces simplified column model for diagram generation. |
| src/DacpacTool/Diagram/MermaidDiagramBuilder.cs | Implements diagram creation + file emission. |
| src/DacpacTool/Diagram/DatabaseModelToMermaid.cs | Renders simplified model as Mermaid erDiagram markdown. |
| src/DacpacTool/Diagram/DacpacModelFactory.cs | Extracts tables/columns/PKs/FKs/types from TSqlModel. |
| src/DacpacTool/BuildOptions.cs | Adds CLI option to enable ER diagram generation. |
| README.md | Documents the new GenerateEntityRelationshipDiagram feature and output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@ErikEJ I would suggest doing an override here so that we can merge this. My guess is that @jeffrosenberg doesn't currently have the bandwidth to review this (which is totally fine) and we already have two reviewers + copilot feedback anyway. |
|
@jmezach sounds good, but only you can override 😳 |
|
@ErikEJ Done. Shall we ship this as 4.1? |
|
Let's do that! |
fixes #867
@jmezach Decided to make it optional, and add to templates to make it visible.