Use metadata to generate entity diagrams
Applies To: Dynamics CRM 2016, Dynamics CRM Online
Visual representation of metadata can be very useful, especially when you are trying to describe the relationship between entities in the system. You can use the Metadata Diagram sample code provided for Microsoft Dynamics CRM Online 2016 Update and Microsoft Dynamics CRM 2016 (on-premises) to generate the entity relationship diagrams. You can create a simple diagram that shows a relationship for just one entity, or a complex diagram that includes dozens of related entities, including custom and system entities.
The following example shows two new custom entities created in Microsoft Dynamics CRM. The first entity represents a bank account and the second entity represents a safe deposit box. The following entity diagram was generated by using the Metadata Diagram tool. It shows the relationship between the new_bankaccount entity, the new_safedepositbox entity, and other entities in the system. The names shown are the logical entity names. Note that if there are multiple relationships between the same two entities, only one line is drawn in the diagram for simplicity.
The following table shows the one-to-many relationships where the primary entity is either bank account or safe deposit box.
Relationship schema name
The following table shows the many-to-one relationships where the primary entity is either bank account or safe deposit box.
Relationship schema name
The account entity that is shown on the diagram represents a bank customer. As a bank customer, you can open several bank accounts, such as checking and savings accounts, and also several safe deposit boxes. This is an example of a many-to-one relationship type between a bank account and a customer, and a safe deposit box and a customer. You can associate multiple activities, such as tasks, emails, and appointments with a bank account. To provide additional information about a bank account or a safe deposit box, you can use notes and attachments.
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. The 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:
To use the sample code that will programmatically generate Microsoft Office Visio metadata diagrams, build and execute the one of these solutions found in the SDK package: SDK\SampleCode\CS\Metadata\Diagram. The folder contains a Readme file with instructions for its use. The code sample is a stand-alone console application that creates an entity relationship diagram. The program requiresMicrosoft Office Visio.
You can run the program at the command prompt. Simply 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 new_bankaccount and new_safedepositbox entities, use the following command:
The name of the generated Visio file is new_bankaccount.vsd.
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 –”new_bankaccount.vsd”:
MetadataDiagramConsole.exe new_bankaccount new_safedepositbox
To avoid overwriting a generated diagram file, you have to rename the first file before you run the second command.
Microsoft Dynamics CRM 2016 and CRM Online
© 2016 Microsoft. All rights reserved. Copyright