End to end create model using MDS API RRS feed

  • Question

  • Please can someone supply an end to end example of using the MDS API to create a model, entity and attributes on the entity?  I'd like particularly to also see how to create relationships between entities (Person to OrgUnit for example) using the API.

    I have written code to create a model, entities and attributes, however, I can't see attributes of my new entities in the MDS website model explorer. If I manage Entities, then I can see that the attributes exist.

    Apologies for number of edits on this post, but I'm learning and up against a deadline. Nothing new hey!

    • Edited by PerthMsDude Wednesday, September 22, 2010 6:42 AM Progress made
    Wednesday, September 22, 2010 3:41 AM


  • Th issue when creating a new Entity in MDS through the API, if you want to see this entity on the Explorer home page by default, is to set the IsBase boolean to TRUE. Doing so tells MDS to show this entity by detault.
    • Marked as answer by PerthMsDude Friday, September 24, 2010 1:11 AM
    Friday, September 24, 2010 1:11 AM

All replies

  • Hi Perth,

    I don't have an end to end example, but maybe we could debug your case step by step.

    Can you give more details on what code do you use, and what the results are?


    Wednesday, September 22, 2010 10:22 AM
  • Thanks for replying Marius,

    I've had quite a bit of success since originally writing the post, so at this moment I'm trying to address the specifics of why, when I explore my model in the MDS website, I don't see attributes, unless I use the "Manage Entities" page. I think now it's because I haven't established a hierarchy. My model is called MasterData and my entity is called Personnel, so I now assume I need some relationship (a hierarchy) to associate these,so that when I explore my model the Personnel entity is displayed by default,with it's attributes.

    So to be clear, I've programatically created a Model, entities,  attributes and attribute groups. I need figure out hierarchie. But my issue remains that when I explore my model I get a blank page, as opposed to when I browse the Customer model, it brings up the default Customer entity and lists its attributes,which is what I want to achieve.

    Any code, inputs?

    Many thanks.

    Wednesday, September 22, 2010 11:35 PM
  • Th issue when creating a new Entity in MDS through the API, if you want to see this entity on the Explorer home page by default, is to set the IsBase boolean to TRUE. Doing so tells MDS to show this entity by detault.
    • Marked as answer by PerthMsDude Friday, September 24, 2010 1:11 AM
    Friday, September 24, 2010 1:11 AM
  • hi

    i would apprciate if u share your example.l'm new to mds


    Tuesday, February 22, 2011 11:45 PM
  • Here are a few resources that might help you:





    We will have more code samples available at the end of March. I'll update this post when we do.


    Suzanne Selhorn [MSFT]
    Monday, February 28, 2011 5:23 PM
  • Where are the examples?

    It's June 16, 2013. I've scoured the web and purchased Tyler Graham’s book which was useless for examples as he used pseudo code you have to figure out for yourself.

    I've found little smatterings here and there on the web (for 2008R2 – am using 2012 and yes there are differences) and the sample on codeplex...let's just say that's another story.

    Is Microsoft serious about this product? Or is this just someone having fun? There are actually corporate companies trying to use this tool.

    My .02.


    Sunday, June 16, 2013 7:34 PM
  • The samples are here: http://sqlserversamples.codeplex.com/wikipage?title=SQL%20Server%202012%20Master%20Data%20Services

    Is there something you are trying to do that you can't find an example of?


    David http://blogs.msdn.com/b/dbrowne/

    Sunday, June 16, 2013 9:17 PM
  • Thnaks for your response

    There's no example(s) of creating domain based type attributes using the API - only freeform type attributes.

    Any examples you may have will be appreciated.


    Tuesday, June 25, 2013 2:55 AM
  • I do this in the MdsModelImport utility:

              var entity = model.Entities.Single(e => e.Identifier.Name == fk.Table.Name);
              var attributes = entity.MemberTypes[0].Attributes;
              var domainAttribute = new MetadataAttribute();
              domainAttribute.Permission = PermissionType.Update;
              domainAttribute.AttributeType = AttributeType.Domain;
              domainAttribute.DataType = AttributeDataType.Text;
              domainAttribute.DataTypeInformation = 25;
              domainAttribute.DisplayWidth = 100;
              domainAttribute.DomainEntityIsFlat = true;
              domainAttribute.DomainEntityPermission = PermissionType.Update;
              domainAttribute.Identifier = new MemberTypeContextIdentifier();
              domainAttribute.Identifier.Name = fk.ReferencedTable.Name;
              domainAttribute.DomainEntityId = new Identifier();
              domainAttribute.DomainEntityId.Name = fk.ReferencedTable.Name;



    David http://blogs.msdn.com/b/dbrowne/

    Tuesday, June 25, 2013 2:24 PM
  • David;

    Thanks for the infromation.

    Why would you do this first: attributes.Add(domainAttribute);
    and not after you have set all the properties for the var

     Will this make sense:

    MetadataCreateRequest createRequest = new MetadataCreateRequest();
    createRequest.Metadata = new Metadata();
    createRequest.Metadata.Attributes = new System.Collections.ObjectModel.Collection<MetadataAttribute> { };
    MetadataAttribute domainAttrib = new MetadataAttribute();
    // Set model id, entity id, and attribute name.
    domainAttrib.Identifier = new MemberTypeContextIdentifier { 
    	Name = fkTableName, 
    	ModelId = new Identifier {Id = modelId }, 
    	EntityId = new Identifier { Id = entityId }, 
    	MemberType = MemberType.Leaf 
    domainAttrib.Permission = PermissionType.Update;
    domainAttrib.AttributeType = AttributeType.Domain;
    domainAttrib.DataType = AttributeDataType.NotSpecified;
    domainAttrib.DataTypeInformation = 25;
    domainAttrib.DisplayWidth = 100;
    domainAttrib.DomainEntityPermission = PermissionType.Update;
    domainAttrib.DomainEntityId = new Identifier();
    domainAttrib.DomainEntityId.Name = fkTableName;


    Tuesday, June 25, 2013 7:16 PM