Is it possible to specify FromRole and ToRole strings and exact cardinality for both ends of an association using IMetadataProvider?
The following code works for defining a new association sets with both ends. The cardinality is automatically selected based on the property's kind between values "0..1" and "*".
The issue is I have no way to specify a cardinality of "1" or "1..*". Neither can I find a way to set the association's ToRole and FromRole, as well as other association info like the Cascade Delete flag.
... // Add navigation properties on both ends // This end ResourcePropertyKind propertyKind = associatedCardinality == Cardinality.ExactlyOne || associatedCardinality == Cardinality.ZeroOne ? ResourcePropertyKind.ResourceReference : ResourcePropertyKind.ResourceSetReference; ResourceProperty property = new ResourceProperty(propertyName, propertyKind, associatedType); property.CanReflectOnInstanceTypeProperty = false; resourceType.AddProperty(property); // Other/associated end ResourcePropertyKind asssociatedPropertyKind = cardinality == Cardinality.ExactlyOne || cardinality == Cardinality.ZeroOne ? ResourcePropertyKind.ResourceReference : ResourcePropertyKind.ResourceSetReference; ResourceProperty associatedProperty = new ResourceProperty(associatedPropertyName, asssociatedPropertyKind, resourceType);
associatedProperty.CanReflectOnInstanceTypeProperty = false; associatedType.AddProperty(associatedProperty); // Create Resource artifacts ResourceAssociationSetEnd associationSetEnd1 = new ResourceAssociationSetEnd(resourceSet, resourceType, property); ResourceAssociationSetEnd associationSetEnd2 = new ResourceAssociationSetEnd(associatedSet, associatedType, associatedProperty); ResourceAssociationSet resourceAssociationSet = new ResourceAssociationSet(associationName, associationSetEnd1, associationSetEnd2); ...
Thanks,
Nima