|
| 1 | +--- |
| 2 | +title: "Use metadata to generate entity diagrams (Developer Guide for Dynamics 365 Customer Engagement (on-premises)) | MicrosoftDocs" |
| 3 | +description: "Learn about using the Metadata Diagram tool to visually show entity relationships for one entity or multiple related entities, including custom and system entities." |
| 4 | +ms.date: 01/04/2023 |
| 5 | +ms.reviewer: jdaly |
| 6 | +ms.topic: article |
| 7 | +author: phecke # GitHub ID |
| 8 | +ms.author: pehecke # MSFT alias of Microsoft employees only |
| 9 | +ms.subservice: dataverse-developer |
| 10 | +search.audienceType: |
| 11 | + - developer |
| 12 | +search.app: |
| 13 | + - PowerApps |
| 14 | + - D365CE |
| 15 | +--- |
| 16 | + |
| 17 | +# Use metadata to generate entity diagrams |
| 18 | + |
| 19 | +Visual representation of metadata can be useful, especially when you are trying to describe the relationship between entities in the system. You can use the Metadata Diagram tool, available as a code sample, to read the Organization web service metadata and generate entity relationship diagrams from that data. |
| 20 | + |
| 21 | +You can create a diagram that shows a relationship for just one entity, or a complex diagram that includes dozens of related entities, including custom and system entities. |
| 22 | + |
| 23 | +## Relationships in entity diagrams |
| 24 | + |
| 25 | +The following example shows a new custom entity named "Safe Deposit Box" created in Power Apps and its relationship to a slightly customized "Bank Account" (account) entity. |
| 26 | + |
| 27 | +The following entity diagram was generated using the Metadata Diagram tool. It shows the relationship between the `account` entity, the custom `new_safedepositbox` entity, and other entities in the system. The names shown are the logical entity names. |
| 28 | + |
| 29 | +> [!NOTE] |
| 30 | +> If there are multiple relationships between the same two entities, only one line is drawn in the diagram for simplicity. |
| 31 | +
|
| 32 | + |
| 33 | + |
| 34 | +You can look up information about relationships for a table in Power Apps. Notice the one-to-many relationship with Safe Deposit Box. |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | +The bank account entity that is shown on the diagram represents a bank account for a customer. As a bank customer, you can open several bank accounts, such as checking and savings accounts, where each bank account can have zero or more safe deposit boxes. This is an example of a one-to-many relationship type between a bank account and safe deposit boxes. |
| 39 | + |
| 40 | +You can associate multiple activities, such as tasks, emails, and appointments with a bank account. THe bank account is associated with a customer, there is contact information on file, and a chat log for support requests is kept. |
| 41 | + |
| 42 | +## About the diagrams |
| 43 | + |
| 44 | +You can find the diagrams for many system entities in the SDK documentation, in the topics that describe the entity capabilities. In each box in the diagram, the first line in bold text is the name of the entity. Subsequent lines contain the names of the attributes used to define the relationships for that entity. |
| 45 | + |
| 46 | +The Metadata Diagram tool does not generate lines showing the relationships to the following entities: organization, business unit, and user (systemuser). This is done to simplify the diagram. Color coding is used to indicate the owner relationship for each entity. The following diagram describes the color coding: |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | +<a name="Generate"></a> |
| 51 | + |
| 52 | +## Generate entity diagrams with the Metadata Diagram tool |
| 53 | + |
| 54 | +To use the Metadata Diagram tool to generate Microsoft Visio metadata diagrams, build and execute the tool code using the provided Visual Studio solution in the code sample's project folder. |
| 55 | + |
| 56 | +Sample source code: [Generate entity diagrams with the metadata diagram tool](https://github.com/microsoft/PowerApps-Samples/tree/master/dataverse/GenerateEntityDiagram) |
| 57 | + |
| 58 | +The project folder contains a Readme file with instructions for building and running the sample. The code sample is a stand-alone console application that creates an entity relationship diagram. The program requires Microsoft Visio to be installed on your computer as it calls Visio library functions to generate the diagram. |
| 59 | + |
| 60 | +You can run the program at the command prompt. List the entities you wish to include in the diagram as command-line arguments. Other entities may be included in your diagram as needed to show all the relationships for each entity you have requested. To generate a diagram that shows the relationships for the account and new_safedepositbox entities, use the following command: |
| 61 | + |
| 62 | +```ms-dos |
| 63 | +GenerateEntityDiagram.exe account new_safedepositbox |
| 64 | +``` |
| 65 | + |
| 66 | +The custom entity new_safedepositbox must exist in your environment for this to work. Otherwise, try any combination of entities that do exist - perhaps "account contact". |
| 67 | +The name of the generated Visio file is account.vsd. |
| 68 | + |
| 69 | +> [!NOTE] |
| 70 | +> The tool uses the name of the first entity on the command line as the name of the Visio file. If you execute the following two commands, the second command overwrites the diagram generated by the first. This is because the Visio files have the same name –”account.vsd”: |
| 71 | +> |
| 72 | +> `GenerateEntityDiagram.exe account` |
| 73 | +> |
| 74 | +> `GenerateEntityDiagram.exe account new_safedepositbox` |
| 75 | +> |
| 76 | +> To avoid overwriting a generated diagram file, you have to rename the first file before you run the second command. |
| 77 | +
|
| 78 | +## Community tools |
| 79 | + |
| 80 | +### UML Diagram Generator |
| 81 | + |
| 82 | +**[UML Diagram Generator](https://jonasr.app/uml?utm_source=msdocs)** for XrmToolBox is a tool that generates Entity Relationship Diagrams ([ERD](https://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model)) in the form of [PlantUML](https://plantuml.com/) files from metadata in Microsoft Dynamics 365 and the Power Platform Dataverse. As the result is text-based files, they can be manually edited and kept in source control for change tracking over time. |
| 83 | + |
| 84 | +**[Entity Relation Diagram Creator](https://www.xrmtoolbox.com/plugins/JourneyIntoCRM.XrmToolbox.ERDPlugin/)** for XrmToolBox is a tool that generates visual Entity Relationship Diagrams from metadata in Microsoft Dynamics 365 and the Power Platform Dataverse. |
| 85 | + |
| 86 | +**[ERD Visio Builder](https://www.xrmtoolbox.com/plugins/LinkeD365.ERDVisioBuilder/)** for XrmToolBox is a tool that generates Visio diagrams from the metadata in Microsoft Dynamics 365 and the Power Platform Dataverse. |
| 87 | + |
| 88 | +See the [Developer tools](developer-tools.md) article for community developed tools, [jonasr.app/uml](https://jonasr.app/uml?utm_source=msdocs) for more information about UML Diagram Generator, [journeyintocrm.com](https://www.journeyintocrm.com/archives/1806.html) for more information about Entity Relation Diagram Creator and [LinkeD365.blog](https://linked365.blog/2020/07/06/erd-visio-builder-xrmtoolbox-addon/) for more information on the ERD Visio Builder. |
| 89 | + |
| 90 | +> [!NOTE] |
| 91 | +> The community tools are not a product of Microsoft and we do not extend support to the community tools. |
| 92 | +> If you have questions pertaining to the tool, please contact the publisher. More Information: [XrmToolBox](https://www.xrmtoolbox.com). |
| 93 | +
|
| 94 | +### See also |
| 95 | + |
| 96 | +[Work with Dataverse tables using code](entities.md) |
| 97 | +[Work with table definitions using code](metadata-services.md) |
| 98 | + |
| 99 | +[!INCLUDE[footer-include](../../includes/footer-banner.md)] |
0 commit comments