ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Data.DDL.Knowledge Namespace / KnowledgeGraphRelationshipTypeDescription Class
Members Example Version

KnowledgeGraphRelationshipTypeDescription Class
Object Model
KnowledgeGraphRelationshipTypeDescription ClassShapeDescription Class
Syntax
public sealed class KnowledgeGraphRelationshipTypeDescription : KnowledgeGraphTypeDescription 
Remarks
There are a number of different constructor overloads provided allowing a relationship type description to be initialized from a number of different sources including:
A table or feature class definition.
A ArcGIS.Core.Data.Knowledge.KnowledgeGraphRelationshipType.
Another KnowledgeGraphRelationshipTypeDescription.
A collection of KnowledgeGraphPropertyDescription.
Various other overloads that also include a name and spatial column ("shape description").
Note: A spatial column for both KnowledgeGraphEntityTypes and KnowledgeGraphRelationshipTypes is optional. KnowledgeGraphEntityTypes and KnowledgeGraphRelationshipTypes created with a shape column will be represented as feature classes in a knowledge graph geodatabase and KnowledgeGraphEntityTypes and KnowledgeGraphRelationshipTypes created without a shape column will be represented as tables.
When initializing a KnowledgeGraphRelationshipTypeDescription, an ObjectID and GlobalID KnowledgeGraphPropertyDescription will automatically be added to the list of property descriptions (if they were not provided as inputs to the relevant constructor) within the ArcGIS.Core.Data.DDL.SchemaBuilder. In the case of the relationship type, the underlying origin and destination entity id fields will also be automatically be added to the list of property descriptions within the ArcGIS.Core.Data.DDL.SchemaBuilder
Example
Create Entity and Relationship Types with SchemaBuilder
await QueuedTask.Run(() =>
{
  using (var kg = GetKnowledgeGraph())
  {
    if (kg == null)
      return;

    var entity_name = "PhoneCall";
    var relate_name = "WhoCalledWho";

    //Entity Fields
    var descs1 =
        new List<KnowledgeGraphPropertyDescription>();
    descs1.Add(
      new KnowledgeGraphPropertyDescription("PhoneOwner", FieldType.String));
    descs1.Add(
      new KnowledgeGraphPropertyDescription("PhoneNumber", FieldType.String));
    descs1.Add(
      new KnowledgeGraphPropertyDescription("LocationID", FieldType.BigInteger));
    descs1.Add(
      new KnowledgeGraphPropertyDescription("DateAndTime", FieldType.Date));

    //Relate Fields
    var descs2 =
        new List<KnowledgeGraphPropertyDescription>();
    descs2.Add(
      new KnowledgeGraphPropertyDescription("Foo", FieldType.String));
    descs2.Add(
      new KnowledgeGraphPropertyDescription("Bar", FieldType.String));


    var includeShape = true;//change to false to omit the shape column
    var hasZ = false;
    var hasM = false;

    KnowledgeGraphEntityTypeDescription entityDesc = null;
    KnowledgeGraphRelationshipTypeDescription relateDesc = null;
    if (includeShape)
    {
      var sr = kg.GetSpatialReference();
      var shp_desc = new ShapeDescription(GeometryType.Point, sr)
      {
        HasM = hasM,
        HasZ = hasZ
      };
      entityDesc = new KnowledgeGraphEntityTypeDescription(
        entity_name, descs1, shp_desc);
      relateDesc = new KnowledgeGraphRelationshipTypeDescription(
        relate_name, descs2, shp_desc);
    }
    else
    {
      entityDesc = new KnowledgeGraphEntityTypeDescription(
        entity_name, descs1);
      relateDesc = new KnowledgeGraphRelationshipTypeDescription(
        relate_name, descs2);
    }
    //Run the schema builder
    try
    {
      SchemaBuilder sb = new(kg);
      sb.Create(entityDesc);
      sb.Create(relateDesc);
      //Use the KnowledgeGraph extension method 'ApplySchemaEdits(...)'
      //to refresh the Pro UI
      if (!kg.ApplySchemaEdits(sb))
      {
        var err_msg = string.Join(",", sb.ErrorMessages.ToArray());
        System.Diagnostics.Debug.WriteLine($"Entity/Relate Create error: {err_msg}");
      }
    }
    catch (Exception ex)
    {
      System.Diagnostics.Debug.WriteLine(ex.ToString());
    }
  }
});
Inheritance Hierarchy

System.Object
   ArcGIS.Core.Data.DDL.Description
      ArcGIS.Core.Data.DDL.Knowledge.KnowledgeGraphTypeDescription
         ArcGIS.Core.Data.DDL.Knowledge.KnowledgeGraphRelationshipTypeDescription

Requirements

Target Platforms: Windows 11, Windows 10

ArcGIS Pro version: 3.4 or higher.
See Also