Can I load a data model (ddl) straight into the back-end of MDS?
-
Monday, February 04, 2013 6:58 PM
I have a DBA/Database Developer background, and I'm trying to learn MDS.
MDS appears to be very front-end centric with hardly any involvement in the back-end. Is there any way to load a data model (like "create table" scripts) directly into the back-end? Or does everything need to be created in the front-end?
All Replies
-
Monday, February 04, 2013 8:06 PMModerator
Hi Emily
you can use API to create a model, but it could be quite long and more complicated than with front end
example for creating an entity: (sample from my mdsmanager project)
public static void CreateEntity(string ModelName, string newEntityName) { OperationResult OperationResult = new OperationResult(); Metadata Metadata = new Metadata(); Identifier identifier = new Identifier() { Name = ModelName }; Metadata.Entities = new Collection<Entity>(); Collection<Entity> entities = Metadata.Entities; Entity entity1 = new Entity(); Entity entity2 = entity1; EntityContextIdentifier contextIdentifier1 = new EntityContextIdentifier(); contextIdentifier1.Name = newEntityName; contextIdentifier1.ModelId = identifier; EntityContextIdentifier contextIdentifier2 = contextIdentifier1; entity2.Identifier = (ModelContextIdentifier)contextIdentifier2; entity1.IsFlat = true; Entity entity3 = entity1; Collection<ExplicitHierarchy> collection1 = new Collection<ExplicitHierarchy>(); Collection<ExplicitHierarchy> collection2 = collection1; ExplicitHierarchy explicitHierarchy1 = new ExplicitHierarchy(); ExplicitHierarchy explicitHierarchy2 = explicitHierarchy1; EntityContextIdentifier contextIdentifier3 = new EntityContextIdentifier(); contextIdentifier3.ModelId = identifier; contextIdentifier3.Name = newEntityName; EntityContextIdentifier contextIdentifier4 = contextIdentifier3; explicitHierarchy2.Identifier = contextIdentifier4; ExplicitHierarchy explicitHierarchy3 = explicitHierarchy1; collection2.Add(explicitHierarchy3); Collection<ExplicitHierarchy> collection3 = collection1; entity3.ExplicitHierarchies = collection3; Entity entity4 = entity1; entities.Add(entity4); using (ServiceClient serviceClient = new ServiceClientWrapper().CreateServiceClient()) serviceClient.MetadataCreate(new International(), Metadata, true, out OperationResult); }
Regards,
Xavier Averbouch
Microsoft Community Contributor
SOAT
If a post answers your question, please click "Mark As Answer" on that post and "Vote as Helpful". -
Wednesday, February 06, 2013 12:46 PM
Hi Emily,
There is an utlity to accomplish this job.
You can download the utility along with the source code from: -
http://mdsutilities.codeplex.com/
The utility to download is: - MDSModelImport.
More details: -
MDSModelImport
A command-line utility to import model metadata from a SQL Server database. For customers who do their data modeling in ERWin or somesuch to get jump-started on their MDS modeling.Usage: MDSModelImport Qualifiers: [-?] Print this help guide. -Server:STRING Source SQL Server -Database:STRING Source Database Name -Model:STRING Name of the MDS Model to create. It must not exist. [-Schema:STRING] Schema to use for import. Default is all schemas. [-MDSEndpoint:STRING] URL to MDS Web Service. Default is in MDSModelImport.exe.config ----------------------------------- Examples MDSModelImport.exe -server (local) -database AdventureWorks -schema HumanResources -model HumanResourcesModel -MDSEndpoint http://localhost/mds/Service/Service.svc
- Marked As Answer by Emily Jones Tuesday, February 19, 2013 1:08 PM
-
Tuesday, February 12, 2013 11:08 AMModerator
Hi Emily
and also the official console tool from MS: MDSModelDeploy
Regards,
Xavier Averbouch
Microsoft Community Contributor
SOAT
If a post answers your question, please click "Mark As Answer" on that post and "Vote as Helpful". -
Tuesday, February 19, 2013 1:12 PMThank you very much! Once I was able to enable the MDS web service (instructions here http://msdn.microsoft.com/en-us/library/hh272581.aspx), I just had to modify the MDSEndpoint in your example above by taking out the "MDS" of the web service connect string (http://localhost/Service/Service.svc is what worked for me).

