ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Data.DDL Namespace / SchemaBuilder Class / Create Method / Create(AttributedRelationshipClassDescription) Method
Indicates the ArcGIS.Core.Data.RelationshipClass to be created.
Example

In This Topic
    Create(AttributedRelationshipClassDescription) Method
    In This Topic
    Enqueue the create operation on the object referred to by the AttributedRelationshipClassDescription. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Exceptions
    ExceptionDescription
    The relationship split policy, relationship rules, and/or the origin foreign key fields are invalid.
    attributedRelationshipClassDescription is null.
    Memory ArcGIS.Core.Data.Geodatabase does not support attributed relationship classes.
    The relationship split policy is not supported.
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Example
    Creating attributed relationship class
    public void CreateAttributedRelationship(SchemaBuilder schemaBuilder)
    {
        // Creating a 'BuildingType' table with two fields - BuildingType and BuildingTypeDescription
        FieldDescription buildingType = FieldDescription.CreateIntegerField("BuildingType");
        FieldDescription buildingTypeeDescription = FieldDescription.CreateStringField("BuildingTypeDescription", 100);
        TableDescription buildingTypeDescription = new TableDescription("BuildingType", new List<FieldDescription>() { buildingType, buildingTypeeDescription });
        TableToken buildingtypeToken = schemaBuilder.Create(buildingTypeDescription);
    
        // Creating a 'Building' feature class with three fields - BuildingId, Address, and BuildingType
        FieldDescription buildingId = FieldDescription.CreateIntegerField("BuildingId");
        FieldDescription buildingAddress = FieldDescription.CreateStringField("Address", 100);
        FeatureClassDescription featureClassDescription = new FeatureClassDescription("Building", new List<FieldDescription> { buildingId, buildingAddress, buildingType }, new ShapeDescription(GeometryType.Polygon, SpatialReferences.WGS84));
        FeatureClassToken buildingToken = schemaBuilder.Create(featureClassDescription);
    
        // Creating M:M relationship between the 'Building' feature class and 'BuildingType' table
        AttributedRelationshipClassDescription attributedRelationshipClassDescription = new AttributedRelationshipClassDescription("BuildingToBuildingType", new FeatureClassDescription(buildingToken),
            new TableDescription(buildingtypeToken), RelationshipCardinality.ManyToMany, "OBJECTID", "BuildingID", "OBJECTID", "BuildingTypeID");
    
        // Adding optional attribute field in the intermediate table - 'OwnershipPercentage' field
        attributedRelationshipClassDescription.FieldDescriptions.Add(FieldDescription.CreateIntegerField("OwnershipPercentage"));
    
        schemaBuilder.Create(attributedRelationshipClassDescription);
        schemaBuilder.Build();
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.1 or higher.
    See Also