Export (0) Print
Expand All

Using Metadata for Generating Entity Diagrams in Microsoft Dynamics CRM 4.0

Inna Agranov
Microsoft Corporation

January 2009

Summary

Learn about the tool that lets you generate Microsoft Office Visio diagrams that display the relationships between entities in Microsoft Dynamics CRM 4.0.

Applies To

Microsoft Dynamics CRM 4.0

Microsoft Visual Studio 2005

Microsoft Office Visio 2003

Introduction

The Microsoft Dynamics CRM metadata contains the description of system and custom entities, attributes and the relationship between entities for an organization. The MetadataService Web service provides the messages that you can use to read or write the metadata. In Microsoft Dynamics CRM 3.0 you used the MetadataService Web service to read the metadata. In Microsoft Dynamics CRM 4.0 you have ability not only to read, but also to change the metadata.

This Web service can be used to perform the following actions.

Read Actions

  • Retrieve the metadata for system or custom entities.

  • Retrieve the attributes for an entity.

  • Retrieve the metadata for a specific attribute such as the possible state names or the picklist values for an attribute.

  • Retrieve all the entities and determine which entities are custom entities.

  • Determine whether the metadata has changed since a previous retrieve.

Write Actions

  • Create a custom entity.

  • Add or update an attribute for an entity, either system or custom.

  • Create or delete a relationship between two entities.

  • Add or remove an option from a picklist attribute.

  • Write an installation and uninstall program for your custom solution.

Metadata Diagrams

Visual representation of the metadata can be very useful, especially when you are trying to describe the relationship between the entities in the system. The Microsoft Dynamics CRM 4.0 Software Development Kit (SDK) contains the Metadata Diagram tool that uses the metadata to generate the entity relationship diagrams. You can create a simple diagram that shows a relationship for just one entity, or a very complex diagram that includes dozens of related entities. You can create the diagrams that show the relationship between custom and system entities.

The following example shows two new custom entities created in Microsoft Dynamics CRM. The first new 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.

5fc9f490-8cc7-4037-b8a9-aecef14368f9

The following table specifies the relationship types between the entities that are shown in the diagram.

 

Entity 1 Entity 2 Relationship

new_bankaccount

activity entities (task, email, appointment, and other activities)

1:N (one-to-many)

new_bankaccount

account

N:1 (many-to-one)

new_safedepositbox

annotation (note)

1:N (one-to-many)

new_safedepositbox

new_bankaccount

N:1 (many-to-one)

new_safedepositbox

account

N:1 (many-to-one)

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.

The Metadata Diagram tool can also create much more complex diagrams. The following example is a diagram for the Marketing Automation area.

ff68f80b-bbce-4fbf-a556-48e37d37da4f

To see the Marketing Automation diagram in detail, download Microsoft Dynamics CRM 4.0 Logical Database Diagrams and open the Marketing Automation diagram. The package contains the diagrams for each area of the product, such as Sales, Service and Marketing. These diagrams let you explore the logical database structure for the entities in a default installation of Microsoft Dynamics CRM 4.0. They are designed to be printed as large posters.

About the Diagrams

You can find the diagrams for many system entities in the Microsoft Dynamics CRM 4.0 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:

Key to entity relationship diagrams

Generating Entity Diagrams with the Metadata Diagram Tool

To use the sample code that will programmatically generate Microsoft Office Visio metadata diagrams, download the Microsoft Dynamics CRM 4.0 Software Development Kit (SDK) from the MSDN Developer Center. After you download and unzip the SDK, navigate to the following folder: \sdk\server\fullsample\metadatadiagram. To build and run the sample code, follow the instructions in the Readme.doc. The code sample is a stand-alone console application that creates an entity relationship diagram. The program requires Microsoft Office Visio 2003.

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 new_bankaccount and new_safedepositbox entities, use the following command:

MetadataDiagramConsole.vshost.exe new_bankaccount new_safedepositbox

The name of the generated Visio file is new_bankaccount.vsd.

noteNote
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 will overwrite the diagram generated by the first. This is because the Visio files have the same name –”new_bankaccount.vsd”:

MetadataDiagramConsole.vshost.exe new_bankaccount

MetadataDiagramConsole.vshost.exe new_bankaccount new_safedepositbox

In order to avoid overwriting a generated diagram file, you have to rename the first file before you run the second command.

Additional Information

Download the Microsoft Dynamics CRM 4.0 Software Development Kit (SDK) from the MSDN Developer Center.

For more information about relationships between the entities, see Entity Relationships.

For more information about Microsoft Dynamics CRM metadata and the Metadata Web service, see Web Services: MetadataService.

Send Us Your Feedback about this Article

We appreciate hearing from you. To send your feedback, click the following link and type your comments in the message body.

noteNote
The subject-line information is used to route your feedback. If you remove or modify the subject line we may be unable to process your feedback.

Send Feedback

 

 

Community Additions

ADD
Show:
© 2014 Microsoft