#CRMVisualSchema – part 2: Entity schema up-and-running

At this moment I’m making some nice progress on visualizing an entity model. In the comment section of my previous article Stefan (*kudos*) pointed me on some alternatives, some of them depend either on Visual Studio or Microsoft Visio. My goal is to create a plugin for XrmToolbox, that can be used free of charge.

SchemaEditor

What have I realized till sofar:

  • Stripped all bloat from the NClass library and rewired it
    The library now fits into a single assembly; containing all application logic required to display the entity schema.
  • Created a test application in which I can load and save entity schemas
    When the schema is reloaded the saved layout is restored.
  • Ensured that entity schema can be saved as a PNG image as well
    This image can be used in design documents or in general documentation.

Furthermore I’ve been working on figuring out how the XML in which the Visual Schema is serialized is set up.

Xml

In fact the schema is straightforward and consists out of two main sections:

<Entities></Entities>

In the Entities section there can be a number of Entity nodes. In the entity layout information is stored as well as field information.

<Relationships></Relationships>

In the Relationships section, all relationships are stored. Per relationship, you have to specify “first” and “second”. “first” specifies the FROM entity and “second” specifies the TO entity.
In “first” and “two”, not the entity names but the index numbers of the entities are stored. When specifying the relationships I have to look at the sequence in which the entities are loaded from the CRM solution. This is the tricky part for now.

Finally I’ve been looking at how the relationships between the CRM entities have to be interpreted, and how I should use the entity relations in the Schema Diagram.

Crm2xml

It turns out that we need to use the OneToMany relationships and the ManyToMany relationships. In the OneToMany relations the “FROM” table is the referencing entity while the “TO” table is the referenced table.  E.g. A Contact is referenced by an Incident.

In case of a many to many relationship we need to create two  <relationship> entries in the XML we use to store the relationships, we just need to swap the “FROM” and “TO” for the two entries.

Crm2xml2

With all this logic in place, I now can focus on building the XrmToolbox plugin. This is something I will do in the next article.

Stay tuned…

Leave a Reply

Your email address will not be published. Required fields are marked *