1

What I want to do is:

  1. Retrieve all metadata from CRM.
  2. Serialize that metadata and store it in a file.
  3. At a later point, deserialize and eed that metadata to XrmFakeEasy for unit tests.

Steps 2 and 3 are done but I don't know how to accomplish step 1. I've spent some time noodling around in the code and on Google but remain stumped.

We're using .Net so what I need is to read ALL the Entity Metadata (type: Microsoft.Xrm.Sdk.Metadata.EntityMetadata).

If anyone knows how to do this or can point me in the direction of the API (I haven't been able to find one) then please let me know.

P.S. This case is for on-premise crm.

Jay
  • 2,827
  • 6
  • 34
  • 49
  • 1
    Is this on-premise or online? – Tobias Kildetoft Jul 01 '20 at 15:44
  • 1
    What do you include in 'all metadata'? Is it entities and attributes? Or is it forms, workflows, plugins, view, dashboard, etc? – Sergey Tunnik Jul 01 '20 at 15:49
  • @TobiasKildetoft it's on-prem – Jay Jul 02 '20 at 08:37
  • @SergeyTunnik I mean anything that the Microsoft.Xrm.Sdk.Metadata.EntityMetadata class can represent. I'm quite new to CRM so please forgive my ignorance (I'm working on it ;) I believe it's only entities (with their attributes etc) as that is what the documentation claims EntityMetadata represents https://docs.microsoft.com/en-us/dotnet/api/microsoft.xrm.sdk.metadata.entitymetadata?view=dynamics-general-ce-9 – Jay Jul 02 '20 at 08:41

2 Answers2

1

If I get it right you need to use RetrieveAllEntitiesRequest request. Here are more details: https://stackoverflow.com/a/29694213/2575544

Sergey Tunnik
  • 408
  • 3
  • 8
1

For the benefit of anyone that comes across this post here's

My final solution

public static EntityMetadata[] GetMetadata(IOrganizationService crmService)
{
    var request = new RetrieveAllEntitiesRequest
    {
        EntityFilters = EntityFilters.All
    };

    var response = (RetrieveAllEntitiesResponse) crmService.Execute(request);
    return response.EntityMetadata;
}
Jay
  • 2,827
  • 6
  • 34
  • 49