Is there a way to create a relationship class between two TABLES with the pro sdk? Here is the code that I have used but the relationship class is not created in the geodatabase like I expect. @CharlesMacleod @Wolf @UmaHarano
var originFc = gdb.OpenDataset<FeatureClass>(mmember.Name);
var destFc = gdb.OpenDataset<FeatureClass>(etTableName);
var oidname = originFc.GetDefinition().GetObjectIDField();
var origPrimaryKey = originFc.GetDefinition().GetFields().First(f => string.Equals(oidname, f.Name));
var destForeignKey = destFc.GetDefinition().GetFields().First(f => string.Equals(ETTableSchema.rowIDFieldName, f.Name));
var rlDesc = new VirtualRelationshipClassDescription(origPrimaryKey, destForeignKey,
RelationshipCardinality.OneToMany);
rlDesc.ForwardPathLabel = "HasEdits";
rlDesc.BackwardPathLabel = "AllObjects";
rlDesc.Name = $"{mmember.Name}_HTE";
var rlClass = originFc.RelateTo(destFc, rlDesc);
Solved! Go to Solution.
We started to add some data definition language (DDL) capabilities in the Pro SDK at 2.8, but you cannot yet create relationship classes (it's planned for a future release). For now, you have to use the geoprocessing API and use the Create Relationship Class tool.
--Rich
We started to add some data definition language (DDL) capabilities in the Pro SDK at 2.8, but you cannot yet create relationship classes (it's planned for a future release). For now, you have to use the geoprocessing API and use the Create Relationship Class tool.
--Rich
@MarvisKisakye1 You probably already looked at this sample: arcgis-pro-sdk-community-samples/Geodatabase/DynamicJoins at master · Esri/arcgis-pro-sdk-community-...
However, the sample only creates a 'dynamic' result (added to the TOC). To create a relationship class in the geodatabase you have to follow Rich's suggestion.