ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Data.DDL Namespace / SchemaBuilder Class / ErrorMessages Property
Example

In This Topic
    ErrorMessages Property (SchemaBuilder)
    In This Topic
    Gets information about failed operations.
    Syntax
    public IReadOnlyList<string> ErrorMessages {get;}
    Public ReadOnly Property ErrorMessages As IReadOnlyList(Of String)
    Remarks
    The first line describes the type of operation. The second line describes the name of the object involved. The next set of lines describes the type of error. The last line describes how long the operation ran for.
    Example
    Creating a Table
    public void CreateTableSnippet(Geodatabase geodatabase, CodedValueDomain inspectionResultsDomain)
    {
        // Create a PoleInspection table with the following fields
        //  GlobalID
        //  ObjectID
        //  InspectionDate (date)
        //  InspectionResults (pre-existing InspectionResults coded value domain)
        //  InspectionNotes (string)
    
        // This static helper routine creates a FieldDescription for a GlobalID field with default values
        FieldDescription globalIDFieldDescription = FieldDescription.CreateGlobalIDField();
    
        // This static helper routine creates a FieldDescription for an ObjectID field with default values
        FieldDescription objectIDFieldDescription = FieldDescription.CreateObjectIDField();
    
        // Create a FieldDescription for the InspectionDate field
        FieldDescription inspectionDateFieldDescription = new FieldDescription("InspectionDate", FieldType.Date)
        {
            AliasName = "Inspection Date"
        };
    
        // This static helper routine creates a FieldDescription for a Domain field (from a pre-existing domain)
        FieldDescription inspectionResultsFieldDescription = FieldDescription.CreateDomainField("InspectionResults", new CodedValueDomainDescription(inspectionResultsDomain));
        inspectionResultsFieldDescription.AliasName = "Inspection Results";
    
        // This static helper routine creates a FieldDescription for a string field
        FieldDescription inspectionNotesFieldDescription = FieldDescription.CreateStringField("InspectionNotes", 512);
        inspectionNotesFieldDescription.AliasName = "Inspection Notes";
    
        // Assemble a list of all of our field descriptions
        List<FieldDescription> fieldDescriptions = new List<FieldDescription>()
    { globalIDFieldDescription, objectIDFieldDescription, inspectionDateFieldDescription, inspectionResultsFieldDescription, inspectionNotesFieldDescription };
    
        // Create a TableDescription object to describe the table to create
        TableDescription tableDescription = new TableDescription("PoleInspection", fieldDescriptions);
    
        // Create a SchemaBuilder object
        SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
    
        // Add the creation of PoleInspection to our list of DDL tasks
        schemaBuilder.Create(tableDescription);
    
        // Execute the DDL
        bool success = schemaBuilder.Build();
    
        // Inspect error messages
        if (!success)
        {
            IReadOnlyList<string> errorMessages = schemaBuilder.ErrorMessages;
            //etc.
        }
    }
    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());
        }
      }
    });
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also