I'm reading pairs of sub-model-name & entity-name from a spreadsheet, and want to add the entities to the submodel, and the relationships between them.
First I'm adding the entities to the sub-models as follows...
For i = 2 To rowcount
submdlName = ..<getting from spreadsheet row, works fine>
eName = ..<getting from spreadsheet row, works fine>
submdl = ..<find submdl, that works fine> submdl.EntityDisplays.Add(eName) Nextis the red line correct? The code above does seem to work ok. The entities do get added to the submodelsbut I then need to add the relationships to the sub-model, which I can't figure out. I'm just guessing. For Each submdl In mdl.SubModels
If Not submdl.MainSubModel Then
For Each eDisp In submdl.EntityDisplays
ent = eDisp.ParentEntity
For Each rel In ent.ParentRelationships ' determine if the parent entity of the relationship is also in the submodel
eDisp = submdl.EntityDisplays.Item(rel.ParentEntity.ID) ???
If eDisp <> Null ??? Then
I couldn't find any sample macros to give clues, and I don't know where else to look for detailed help.
Take a look at the macro called:
IMPORT OBJECT DEFINITION AND NOTES FROM EXCEL
To me the example macro named 'Import Relationships From Excel.bas' sounds very similar to what you are doing. I've never done it so I have no working code to share but I do know (from this thread https://community.idera.com/database-tools/databasedevelopment/database-administration/data-modeling--architecture/f/macros/25804/changing-layout-relationship) that there are 2 pieces to a relationship: the relationship itself and the display of the relationship. So you need to first add the relationship if it doesn't exist and then add it's visibility to models where it should appear.
Thanks Arthur, I've been using that macro for some other purposes, but it doesn't deal with the 'RelationshipDisplays' issue. I think the 'Import Relationships From Excel.bas' mentioned by someone will do it.
thank you, this will definitely gives me some hints. The relationships do actually already exist in the main model, so I am just trying to make them visible in the sub-models. I used another macro to make the entities visible in sub-models,but the relationships did not come along too.