This is a quick post on how to generate Data Model and Entity Relationship Diagram (ERD) Visio diagram for a Dynamics CRM implementation using the metadata application in the Dynamics CRM SDK.
Download and unpack Dynamics CRM SDK somewhere onto your machine. You can download Dynamics CRM 2011 (or 0nline) SDK from this location url:
In your SDK unpacked location, you will find the following sample code for data model and ERD diagram generation (Visio):
Open the visual Studio solution (metadatadiagram.sln) and then build the Visual Studio solution (in release mode rather than debug). Once the visual studio project runs successfully, you will find a new release (or debug) folder under your bin folder: SDK\SampleCode\CS\metadata\diagram\bin\release
In this file you will find your file: Metadatadiagramconsole.exe
Run a command prompt as administrator (right click run as administrator) and then navigate to your exe file location. Type in the file name: Metadatadiagramconsole.exe and then press enter.
You will have the console application running and it will take you through the process to choose which CRM server and which organisation to connect to.
Select your chosen configuration (if you already have one setup) or create a new one.
The metadata diagram in Visio will be created for you in the bin folder under your debug or release folder.
One important note: If you run the command for the file Metadatadiagramconsole.exe it will generate the data model for absolutely all CRM entities which will be a very big and unreadable Visio file. You should limit your diagram to the entities you require so in this case your command line will be:
Metadatadiagramconsole.exe contact account
instead of the general command:
which will generate ERD for every single CRM entity which is huge and will probably take forever (haven’t dared to try it).
Hope this helps.