ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Core.Data.DDL Namespace / SchemaBuilder Class / Build Method
Example

In This Topic
    Build Method (SchemaBuilder)
    In This Topic
    Performs all enqueued operations. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public bool Build()
    Public Function Build() As Boolean

    Return Value

    True ,if all operations ran successfully; otherwise False. Any returned errors and error messages can be accessed in ErrorMessages
    Exceptions
    ExceptionDescription
    There are no enqueued operations to run.
    A geodatabase-related exception has occurred.
    This operation cannot be invoked inside Geodatabase.ApplyEdits() or when editing is in progress.
    This operation cannot be invoked when editing is in progress.
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Remarks
    If an edit session is in progress on the specified geodatabase or knowledge graph an InvalidOperationException will be thrown.
    When using the Pro SDK Add-In-based DDL, do not perform DDL operations while the dataset is open in the map. Remove the dataset before making changes, and add it back after completing the operation.
    If executing schema operations on a knowledge graph from within an Add-In, to ensure proper refresh of the application UI, schema builder operations should be executed within a call to knowledgeGraph.ApplySchemaEdits(sb) where the knowledge graph is the same knowledge graph used initialize the schema builder via its constructor. Calling schemaBuilder.Build() directly when it has been constructed with a knowledge graph may result in the application UI not refreshing correctly. Additionally, calling knowledgeGraph.ApplySchemaEdits(sb) when the schema builder was initialized with a geodatabase (not a knowledge graph) will result in an InvalidOperationException.

    Currently, the following operations are supported for knowledge graphs:
     o Create (named object types and attribute index)
     o Delete named object types
     o Modify*

    *Refer to Modify(KnowledgeGraphTypeDescription) for specific details on what modifications can be made to knowledge graph named object type schemas.
    Example
    Creating a Table
    {
      Task CreateTableSnippetAsync(Geodatabase geodatabase, CodedValueDomain inspectionResultsDomain) => QueuedTask.Run(() =>
      {
        // Create a PoleInspection table with the following fields
        // GlobalID
        // ObjectID
        // InspectionDate (date)
        // InspectionResults (pre-existing InspectionResults coded value domain)
        // InspectionNotes (string)
    
        // This helper routine creates a FieldDescription for a GlobalID field with default values
        FieldDescription globalIDFieldDescription = FieldDescription.CreateGlobalIDField();
    
        // This 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 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 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.
        }
      });
    }
    Creating a feature class
    {
      Task CreateFeatureClassSnippetAsync(Geodatabase geodatabase, FeatureClass existingFeatureClass,
        SpatialReference spatialReference) => QueuedTask.Run(() =>
      {
        // Create a Cities feature class with the following fields
        // GlobalID
        // ObjectID
        // Name (string)
        // Population (integer)
    
        // This helper routine creates a FieldDescription for a GlobalID field with default values
        FieldDescription globalIDFieldDescription = FieldDescription.CreateGlobalIDField();
    
        // This helper routine creates a FieldDescription for an ObjectID field with default values
        FieldDescription objectIDFieldDescription = FieldDescription.CreateObjectIDField();
    
        // This helper routine creates a FieldDescription for a string field
        FieldDescription nameFieldDescription = FieldDescription.CreateStringField("Name", 255);
    
        // This helper routine creates a FieldDescription for an integer field
        FieldDescription populationFieldDescription = FieldDescription.CreateIntegerField("Population");
    
        // Assemble a list of all of our field descriptions
        List<FieldDescription> fieldDescriptions = new List<FieldDescription>()
            { globalIDFieldDescription, objectIDFieldDescription, nameFieldDescription, populationFieldDescription };
    
        // Create a ShapeDescription object
        ShapeDescription shapeDescription = new ShapeDescription(GeometryType.Point, spatialReference);
    
        // Alternatively, ShapeDescriptions can be created from another feature class.  In this case, the new feature class will inherit the same shape properties of the existing class
        ShapeDescription alternativeShapeDescription = new ShapeDescription(existingFeatureClass.GetDefinition());
    
        // Enable support for measure (M) value, if needed
        // shapeDescription.HasM = true;
    
        // Enable support for the vertical coordinate system (Z), if needed
        // shapeDescription.HasZ = true;
    
        // Create a FeatureClassDescription object to describe the feature class to create
        FeatureClassDescription featureClassDescription =
          new FeatureClassDescription("Cities", fieldDescriptions, shapeDescription);
    
        // Create a SchemaBuilder object
        SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
    
        // Add the creation of the Cities feature class to our list of DDL tasks
        schemaBuilder.Create(featureClassDescription);
    
        // Execute the DDL
        bool success = schemaBuilder.Build();
    
        // Inspect error messages
        if (!success)
        {
          IReadOnlyList<string> errorMessages = schemaBuilder.ErrorMessages;
          //etc.
        }
      });
    }
    Deleting a Table
    {
      Task DeleteTableSnippetAsync(Geodatabase geodatabase, Table table) => QueuedTask.Run(() =>
      {
        // Create a TableDescription object
        TableDescription tableDescription = new TableDescription(table.GetDefinition());
    
        // Create a SchemaBuilder object
        SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
    
        // Add the deletion of the table to our list of DDL tasks
        schemaBuilder.Delete(tableDescription);
    
        // Execute the DDL
        bool success = schemaBuilder.Build();
      });
    }
    Deleting a Feature Class
    {
      Task DeleteFeatureClassSnippetAsync(Geodatabase geodatabase, FeatureClass featureClass) => QueuedTask.Run(() =>
      {
        // Create a FeatureClassDescription object
        FeatureClassDescription featureClassDescription = new FeatureClassDescription(featureClass.GetDefinition());
    
        // Create a SchemaBuilder object
        SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
    
        // Add the deletion fo the feature class to our list of DDL tasks
        schemaBuilder.Delete(featureClassDescription);
    
        // Execute the DDL
        bool success = schemaBuilder.Build();
      });
    }
    Creating a Range domain
    {
      Task CreateRangeDomainSnippetAsync(Geodatabase geodatabase) => QueuedTask.Run(() =>
      {
        // Create a range description with minimum value = 0 and maximum value = 1000
        RangeDomainDescription rangeDomainDescriptionMinMax = new RangeDomainDescription("RangeDomain_0_1000",
            FieldType.Integer, 0, 1000)
        {
          Description = "Domain value ranges from 0 to 1000"
        };
    
        SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
    
        // Create  a range domain
        schemaBuilder.Create(rangeDomainDescriptionMinMax);
        schemaBuilder.Build();
      });
    }
    Creating a CodedValue domain
    {
      Task CreateCodedDomainSnippetAsync(Geodatabase geodatabase) => QueuedTask.Run(() =>
      {
        // Create a CodedValueDomain description for water pipes
        CodedValueDomainDescription codedValueDomainDescription = new CodedValueDomainDescription("WaterPipeTypes",
          FieldType.String, new SortedList<object, string> { { "C_1", "Copper" }, { "S_2", "Steel" } })
        {
          SplitPolicy = SplitPolicy.Duplicate,
          MergePolicy = MergePolicy.DefaultValue
        };
    
        SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
    
        // Create a coded value domain
        CodedValueDomainToken codedValueDomainToken = schemaBuilder.Create(codedValueDomainDescription);
        schemaBuilder.Build();
      });
    }
    Creating a FeatureDataset
    {
      Task CreateFeatureDatasetSnippetAsync(Geodatabase geodatabase) => QueuedTask.Run(() =>
      {
        // Creating a FeatureDataset named as 'Parcel_Information'
        SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
    
        // Create a FeatureDataset named as 'Parcel Information'
        FeatureDatasetDescription featureDatasetDescription = new FeatureDatasetDescription("Parcel_Information", SpatialReferences.WGS84);
        schemaBuilder.Create(featureDatasetDescription);
    
        // Build status
        bool buildStatus = schemaBuilder.Build();
    
        // Build errors
        if (!buildStatus)
        {
          IReadOnlyList<string> errors = schemaBuilder.ErrorMessages;
        }
      });
    }
    Deleting a FeatureDataset
    {
      Task DeleteFeatureDatasetSnippetAsync(Geodatabase geodatabase) => QueuedTask.Run(() =>
      {
        // Deleting a FeatureDataset named as 'Parcel_Information'
        FeatureDatasetDefinition featureDatasetDefinition = geodatabase.GetDefinition<FeatureDatasetDefinition>("Parcel_Information");
        FeatureDatasetDescription featureDatasetDescription = new FeatureDatasetDescription(featureDatasetDefinition);
    
        SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
    
        // Delete an existing feature dataset named as 'Parcel_Information'
        schemaBuilder.Delete(featureDatasetDescription);
        schemaBuilder.Build();
      });
    }
    Renaming a FeatureDataset
    {
      Task RenameFeatureDatasetSnippetAsync(Geodatabase geodatabase) => QueuedTask.Run(() =>
      {
        // Renaming a FeatureDataset from 'Parcel_Information' to 'Parcel_Information_With_Tax_Jurisdiction'
        string originalDatasetName = "Parcel_Information";
        string datasetRenameAs = "Parcel_Information_With_Tax_Jurisdiction";
    
        FeatureDatasetDefinition originalDatasetDefinition = geodatabase.GetDefinition<FeatureDatasetDefinition>(originalDatasetName);
        FeatureDatasetDescription originalFeatureDatasetDescription = new FeatureDatasetDescription(originalDatasetDefinition);
    
        SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
    
        // Rename the existing FeatureDataset, 'Parcel_Information' to 'Parcel_Information_With_Tax_Jurisdiction'
        schemaBuilder.Rename(originalFeatureDatasetDescription, datasetRenameAs);
        schemaBuilder.Build();
      });
    }
    Creating a FeatureDataset with a FeatureClass in one operation
    {
      Task CreateFeatureDatasetWithFeatureClassSnippetAsync(Geodatabase geodatabase) => QueuedTask.Run(() =>
      {
        // Creating a FeatureDataset named as 'Parcel_Information' and a FeatureClass with name 'Parcels' in one operation
        string featureDatasetName = "Parcel_Information";
        string featureClassName = "Parcels";
    
        SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
    
        // Create a FeatureDataset token
        FeatureDatasetDescription featureDatasetDescription = new FeatureDatasetDescription(featureDatasetName, SpatialReferences.WGS84);
        FeatureDatasetToken featureDatasetToken = schemaBuilder.Create(featureDatasetDescription);
    
        // Create a FeatureClass description
        FeatureClassDescription featureClassDescription = new FeatureClassDescription(featureClassName,
          new List<FieldDescription>()
          {
              new FieldDescription("Id", FieldType.Integer),
              new FieldDescription("Address", FieldType.String)
          },
          new ShapeDescription(GeometryType.Point, SpatialReferences.WGS84));
    
        // Create a FeatureClass inside a FeatureDataset
        FeatureClassToken featureClassToken = schemaBuilder.Create(
          new FeatureDatasetDescription(featureDatasetToken),
          featureClassDescription);
    
        // Build status
        bool buildStatus = schemaBuilder.Build();
    
        // Build errors
        if (!buildStatus)
        {
          IReadOnlyList<string> errors = schemaBuilder.ErrorMessages;
        }
      });
    }
    Creating a FeatureClass in existing FeatureDataset
    {
      Task CreateFeatureClassInsideFeatureDatasetSnippetAsync(Geodatabase geodatabase) => QueuedTask.Run(() =>
      {
        // Creating a FeatureClass named as 'Tax_Jurisdiction' in existing FeatureDataset with name 'Parcels_Information'
        string featureDatasetName = "Parcels_Information";
        string featureClassName = "Tax_Jurisdiction";
    
        // Create a FeatureClass description
        FeatureClassDescription featureClassDescription = new FeatureClassDescription(featureClassName,
          new List<FieldDescription>()
          {
              new FieldDescription("Tax_Id", FieldType.Integer),
              new FieldDescription("Address", FieldType.String)
          },
          new ShapeDescription(GeometryType.Point, SpatialReferences.WGS84));
    
        FeatureDatasetDefinition featureDatasetDefinition = geodatabase.GetDefinition<FeatureDatasetDefinition>(featureDatasetName);
    
        SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
    
        // Create a FeatureClass inside a FeatureDataset using a FeatureDatasetDefinition
        schemaBuilder.Create(new FeatureDatasetDescription(featureDatasetDefinition), featureClassDescription);
    
        // Build status
        bool buildStatus = schemaBuilder.Build();
    
        // Build errors
        if (!buildStatus)
        {
          IReadOnlyList<string> errors = schemaBuilder.ErrorMessages;
        }
      });
    }
    Adding a FeatureClass to a FeatureDataset
    {
      Task AddFeatureClassToFeatureDatasetSnippetAsync(Geodatabase geodatabase) => QueuedTask.Run(() =>
      {
        // Adding a FeatureClass with name 'Tax_Jurisdiction' into a FeatureDataset named as 'Parcels_Information'
        string featureDatasetName = "Parcels_Information";
        string featureClassNameToAdd = "Tax_Jurisdiction";
    
        FeatureDatasetDefinition featureDatasetDefinition = geodatabase.GetDefinition<FeatureDatasetDefinition>(featureDatasetName);
        FeatureDatasetDescription featureDatasetDescription = new FeatureDatasetDescription(featureDatasetDefinition);
    
        FeatureClassDefinition featureClassDefinition = geodatabase.GetDefinition<FeatureClassDefinition>(featureClassNameToAdd);
        FeatureClassDescription featureClassDescription = new FeatureClassDescription(featureClassDefinition);
    
        SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
    
        // Add the 'Tax_Jurisdiction' FeatureClass to the 'Parcels_Information' FeatureDataset
        schemaBuilder.AddFeatureClass(featureDatasetDescription, featureClassDescription);
        bool addStatus = schemaBuilder.Build();
    
        if (!addStatus)
        {
          IReadOnlyList<string> errors = schemaBuilder.ErrorMessages;
        }
      });
    }
    Renaming a Table
    {
      Task RenameTableSnippetAsync(Geodatabase geodatabase) => QueuedTask.Run(() =>
      {
        // Renaming a table from 'Original_Table' to 'Renamed_Table'
        string tableToBeRenamed = "Original_Table";
        string tableRenameAs = "Renamed_Table";
    
        TableDefinition tableDefinition = geodatabase.GetDefinition<TableDefinition>(tableToBeRenamed);
    
        SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
    
        // Table rename
        schemaBuilder.Rename(new TableDescription(tableDefinition), tableRenameAs);
        schemaBuilder.Build();
      });
    }
    Adding fields to a FeatureClass
    {
      Task AddFieldsInFeatureClassSnippetAsync(Geodatabase geodatabase) => QueuedTask.Run(() =>
      {
        // Adding following fields to the 'Parcels' FeatureClass
        // Global ID
        // Parcel_ID
        // Tax_Code
        // Parcel_Address
    
        // The FeatureClass to add fields
        string featureClassName = "Parcels";
    
        FeatureClassDefinition originalFeatureClassDefinition = geodatabase.GetDefinition<FeatureClassDefinition>(featureClassName);
        FeatureClassDescription originalFeatureClassDescription = new FeatureClassDescription(originalFeatureClassDefinition);
    
        // The four new fields to add on the 'Parcels' FeatureClass
        FieldDescription globalIdField = FieldDescription.CreateGlobalIDField();
        FieldDescription parcelIdDescription = new FieldDescription("Parcel_ID", FieldType.GUID);
        FieldDescription taxCodeDescription = FieldDescription.CreateIntegerField("Tax_Code");
        FieldDescription addressDescription = FieldDescription.CreateStringField("Parcel_Address", 150);
    
        List<FieldDescription> fieldsToAdd = new List<FieldDescription>
          {
            globalIdField, parcelIdDescription,
            taxCodeDescription, addressDescription
          };
    
        // Add new fields on the new FieldDescription list
        List<FieldDescription> modifiedFieldDescriptions = new List<FieldDescription>(originalFeatureClassDescription.FieldDescriptions);
        modifiedFieldDescriptions.AddRange(fieldsToAdd);
    
        // The new FeatureClassDescription with additional fields
        FeatureClassDescription modifiedFeatureClassDescription = new FeatureClassDescription(originalFeatureClassDescription.Name,
          modifiedFieldDescriptions, originalFeatureClassDescription.ShapeDescription);
    
        SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
    
        // Update the 'Parcels' FeatureClass with newly added fields
        schemaBuilder.Modify(modifiedFeatureClassDescription);
        bool modifyStatus = schemaBuilder.Build();
    
        if (!modifyStatus)
        {
          IReadOnlyList<string> errors = schemaBuilder.ErrorMessages;
        }
      });
    }
    Adding a Field that uses a domain
    {
      Task AddFieldWithDomainSnippetAsync(Geodatabase geodatabase) => QueuedTask.Run(() =>
      {
        //The FeatureClass to add field
        string featureClassName = "Pipes";
    
        SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
    
        // Create a CodedValueDomain description for water pipes
        CodedValueDomainDescription pipeDomainDescription = new CodedValueDomainDescription("WaterPipeTypes",
          FieldType.String, new SortedList<object, string>
          {
              { "C_1", "Copper" },
              { "S_2", "Steel" }
          })
        {
          SplitPolicy = SplitPolicy.Duplicate,
          MergePolicy = MergePolicy.DefaultValue
        };
    
        // Create a coded value domain token
        CodedValueDomainToken codedValueDomainToken = schemaBuilder.Create(pipeDomainDescription);
    
        // Create a new description from domain token
        CodedValueDomainDescription codedValueDomainDescription = new CodedValueDomainDescription(codedValueDomainToken);
    
        // Create a field named as 'PipeType' using a domain description
        FieldDescription domainFieldDescription = new FieldDescription("PipeType", FieldType.String);
        domainFieldDescription.SetDomainDescription(codedValueDomainDescription);
    
        //Retrieve existing information for 'Pipes' FeatureClass
        FeatureClassDefinition originalFeatureClassDefinition = geodatabase.GetDefinition<FeatureClassDefinition>(featureClassName);
        FeatureClassDescription originalFeatureClassDescription =
          new FeatureClassDescription(originalFeatureClassDefinition);
    
        // Add domain field on existing fields
        // Adding a field,'PipeType', which uses the coded value domain to the 'Pipes' FeatureClass
        List<FieldDescription> modifiedFieldDescriptions = new List<FieldDescription>(originalFeatureClassDescription.FieldDescriptions)
          { domainFieldDescription };
    
        // Create a new description with updated fields for 'Pipes' FeatureClass
        FeatureClassDescription featureClassDescription = new FeatureClassDescription(originalFeatureClassDescription.Name, modifiedFieldDescriptions,
          originalFeatureClassDescription.ShapeDescription);
    
        // Update the 'Pipes' FeatureClass with domain field
        schemaBuilder.Modify(featureClassDescription);
    
        // Build status
        bool buildStatus = schemaBuilder.Build();
    
        // Build errors
        if (!buildStatus)
        {
          IReadOnlyList<string> errors = schemaBuilder.ErrorMessages;
        }
      });
    }
    Removing fields from a Table
    {
      Task RemoveFieldTableSnippetAsync(Geodatabase geodatabase) => QueuedTask.Run(() =>
      {
        // Removing all fields from 'Parcels' table except following
        // Tax_Code
        // Parcel_Address
    
        // The table to remove fields
        string tableName = "Parcels";
    
        TableDefinition tableDefinition = geodatabase.GetDefinition<TableDefinition>(tableName);
        IReadOnlyList<Field> fields = tableDefinition.GetFields();
    
        // Existing fields from 'Parcels' table
        Field taxCodeField = fields.First(f => f.Name.Equals("Tax_Code"));
        Field parcelAddressField = fields.First(f => f.Name.Equals("Parcel_Address"));
    
        FieldDescription taxFieldDescription = new FieldDescription(taxCodeField);
        FieldDescription parcelAddressFieldDescription = new FieldDescription(parcelAddressField);
    
        // Fields to retain in modified table
        List<FieldDescription> fieldsToBeRetained = new List<FieldDescription>()
          {
            taxFieldDescription, parcelAddressFieldDescription
          };
    
        // New description of the 'Parcels' table with the 'Tax_Code' and 'Parcel_Address' fields
        TableDescription modifiedTableDescription = new TableDescription(tableName, fieldsToBeRetained);
    
        SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
    
        // Remove all fields except the 'Tax_Code' and 'Parcel_Address' fields
        schemaBuilder.Modify(modifiedTableDescription);
        schemaBuilder.Build();
      });
    }
    Creating an annotation feature class
    {
      Task CreateStandAloneAnnotationFeatureClassAsync(
        Geodatabase geodatabase, SpatialReference spatialReference) => QueuedTask.Run(() =>
      {
        // Creating a Cities annotation feature class
        // with following user defined fields
        // Name
        // GlobalID
    
        // Annotation feature class name
        string annotationFeatureClassName = "CitiesAnnotation";
    
        // Create user defined attribute fields for annotation feature class
        FieldDescription globalIDFieldDescription = FieldDescription.CreateGlobalIDField();
        FieldDescription nameFieldDescription = FieldDescription.CreateStringField("Name", 255);
    
        // Create a list of all field descriptions
        List<FieldDescription> fieldDescriptions = new List<FieldDescription>
            { globalIDFieldDescription, nameFieldDescription };
    
        // Create a ShapeDescription object
        ShapeDescription shapeDescription = new ShapeDescription(GeometryType.Polygon, spatialReference);
    
        // Create general placement properties for Maplex engine
        CIMMaplexGeneralPlacementProperties generalPlacementProperties =
          new CIMMaplexGeneralPlacementProperties
          {
            AllowBorderOverlap = true,
            PlacementQuality = MaplexQualityType.High,
            DrawUnplacedLabels = true,
            InvertedLabelTolerance = 1.0,
            RotateLabelWithDisplay = true,
            UnplacedLabelColor = new CIMRGBColor
            {
              R = 0,
              G = 255,
              B = 0,
              Alpha = 0.5f // Green
            }
          };
    
        // Create general placement properties for Standard engine
    
        //CIMStandardGeneralPlacementProperties generalPlacementProperties =
        //  new CIMStandardGeneralPlacementProperties
        //  {
        //    DrawUnplacedLabels = true,
        //    InvertedLabelTolerance = 3.0,
        //    RotateLabelWithDisplay = true,
        //    UnplacedLabelColor = new CIMRGBColor
        //    {
        //      R = 255, G = 0, B = 0, Alpha = 0.5f // Red
        //    }
        //   };
    
    
        // Create annotation  label classes
        // Green label
        CIMLabelClass greenLabelClass = new CIMLabelClass
        {
          Name = "Green",
          ExpressionTitle = "Expression-Green",
          ExpressionEngine = LabelExpressionEngine.Arcade,
          Expression = "$feature.OBJECTID",
          ID = 1,
          Priority = 0,
          Visibility = true,
          TextSymbol = new CIMSymbolReference
          {
            Symbol = new CIMTextSymbol()
            {
              Angle = 45,
              FontType = FontType.Type1,
              FontFamilyName = "Tahoma",
              FontEffects = FontEffects.Normal,
              HaloSize = 2.0,
    
              Symbol = new CIMPolygonSymbol
              {
                SymbolLayers = new CIMSymbolLayer[]
                {
                    new CIMSolidFill
                    {
                      Color = CIMColor.CreateRGBColor(0, 255, 0)
                    }
                },
                UseRealWorldSymbolSizes = true
              }
            },
            MaxScale = 0,
            MinScale = 0,
            SymbolName = "TextSymbol-Green"
          },
          StandardLabelPlacementProperties = new CIMStandardLabelPlacementProperties
          {
            AllowOverlappingLabels = true,
            LineOffset = 1.0
          },
          MaplexLabelPlacementProperties = new CIMMaplexLabelPlacementProperties
          {
            AlignLabelToLineDirection = true,
            AvoidPolygonHoles = true
          }
        };
    
        // Blue label
        CIMLabelClass blueLabelClass = new CIMLabelClass
        {
          Name = "Blue",
          ExpressionTitle = "Expression-Blue",
          ExpressionEngine = LabelExpressionEngine.Arcade,
          Expression = "$feature.OBJECTID",
          ID = 2,
          Priority = 0,
          Visibility = true,
          TextSymbol = new CIMSymbolReference
          {
            Symbol = new CIMTextSymbol()
            {
              Angle = 45,
              FontType = FontType.Type1,
              FontFamilyName = "Consolas",
              FontEffects = FontEffects.Normal,
              HaloSize = 2.0,
    
              Symbol = new CIMPolygonSymbol
              {
                SymbolLayers = new CIMSymbolLayer[]
                {
                    new CIMSolidFill
                    {
                      Color = CIMColor.CreateRGBColor(0, 0, 255)
                    }
                },
                UseRealWorldSymbolSizes = true
              }
            },
            MaxScale = 0,
            MinScale = 0,
            SymbolName = "TextSymbol-Blue"
          },
          StandardLabelPlacementProperties = new CIMStandardLabelPlacementProperties
          {
            AllowOverlappingLabels = true,
            LineOffset = 1.0
          },
          MaplexLabelPlacementProperties = new CIMMaplexLabelPlacementProperties
          {
            AlignLabelToLineDirection = true,
            AvoidPolygonHoles = true
          }
        };
    
        // Create a list of labels
        List<CIMLabelClass> labelClasses = new List<CIMLabelClass> { greenLabelClass, blueLabelClass };
    
        // Create an annotation feature class description object to describe the feature class to create
        AnnotationFeatureClassDescription annotationFeatureClassDescription =
          new AnnotationFeatureClassDescription(annotationFeatureClassName, fieldDescriptions, shapeDescription,
            generalPlacementProperties, labelClasses)
          {
            IsAutoCreate = true,
            IsSymbolIDRequired = false,
            IsUpdatedOnShapeChange = true
          };
    
        // Create a SchemaBuilder object
        SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
    
        // Add the creation of the Cities annotation feature class to the list of DDL tasks
        schemaBuilder.Create(annotationFeatureClassDescription);
    
        // Execute the DDL
        bool success = schemaBuilder.Build();
    
        // Inspect error messages
        if (!success)
        {
          IReadOnlyList<string> errorMessages = schemaBuilder.ErrorMessages;
          //etc.
        }
      });
    }
    Creating a feature-linked annotation feature class
    {
      Task CreateFeatureLinkedAnnotationFeatureClassAsync(Geodatabase geodatabase,
        SpatialReference spatialReference) => QueuedTask.Run(() =>
      {
        // Creating a feature-linked annotation feature class between water pipe and valve in water distribution network
        // with following user defined fields
        // PipeName
        // GlobalID
    
        // Annotation feature class name
        string annotationFeatureClassName = "WaterPipeAnnotation";
    
        // Create user defined attribute fields for annotation feature class
        FieldDescription pipeGlobalID = FieldDescription.CreateGlobalIDField();
        FieldDescription nameFieldDescription = FieldDescription.CreateStringField("Name", 255);
    
        // Create a list of all field descriptions
        List<FieldDescription> fieldDescriptions = new List<FieldDescription>
            { pipeGlobalID, nameFieldDescription };
    
        // Create a ShapeDescription object
        ShapeDescription shapeDescription = new ShapeDescription(GeometryType.Polygon, spatialReference);
    
        // Create general placement properties for Maplex engine
        CIMMaplexGeneralPlacementProperties generalPlacementProperties = new CIMMaplexGeneralPlacementProperties
        {
          AllowBorderOverlap = true,
          PlacementQuality = MaplexQualityType.High,
          DrawUnplacedLabels = true,
          InvertedLabelTolerance = 1.0,
          RotateLabelWithDisplay = true,
          UnplacedLabelColor = new CIMRGBColor
          {
            R = 255,
            G = 0,
            B = 0,
            Alpha = 0.5f
          }
        };
    
        // Create annotation  label classes
        // Green label
        CIMLabelClass greenLabelClass = new CIMLabelClass
        {
          Name = "Green",
          ExpressionTitle = "Expression-Green",
          ExpressionEngine = LabelExpressionEngine.Arcade,
          Expression = "$feature.OBJECTID",
          ID = 1,
          Priority = 0,
          Visibility = true,
          TextSymbol = new CIMSymbolReference
          {
            Symbol = new CIMTextSymbol()
            {
              Angle = 45,
              FontType = FontType.Type1,
              FontFamilyName = "Tahoma",
              FontEffects = FontEffects.Normal,
              HaloSize = 2.0,
    
              Symbol = new CIMPolygonSymbol
              {
                SymbolLayers = new CIMSymbolLayer[]
                {
                    new CIMSolidFill
                    {
                      Color = CIMColor.CreateRGBColor(0, 255, 0)
                    }
                },
                UseRealWorldSymbolSizes = true
              }
            },
            MaxScale = 0,
            MinScale = 0,
            SymbolName = "TextSymbol-Green"
          },
          StandardLabelPlacementProperties = new CIMStandardLabelPlacementProperties
          {
            AllowOverlappingLabels = true,
            LineOffset = 1.0
          },
          MaplexLabelPlacementProperties = new CIMMaplexLabelPlacementProperties
          {
            AlignLabelToLineDirection = true,
            AvoidPolygonHoles = true
          }
        };
    
        // Blue label
        CIMLabelClass blueLabelClass = new CIMLabelClass
        {
          Name = "Blue",
          ExpressionTitle = "Expression-Blue",
          ExpressionEngine = LabelExpressionEngine.Arcade,
          Expression = "$feature.OBJECTID",
          ID = 2,
          Priority = 0,
          Visibility = true,
          TextSymbol = new CIMSymbolReference
          {
            Symbol = new CIMTextSymbol()
            {
              Angle = 45,
              FontType = FontType.Type1,
              FontFamilyName = "Consolas",
              FontEffects = FontEffects.Normal,
              HaloSize = 2.0,
    
              Symbol = new CIMPolygonSymbol
              {
                SymbolLayers = new CIMSymbolLayer[]
                {
                    new CIMSolidFill
                    {
                      Color = CIMColor.CreateRGBColor(0, 0, 255)
                    }
                },
                UseRealWorldSymbolSizes = true
              }
            },
            MaxScale = 0,
            MinScale = 0,
            SymbolName = "TextSymbol-Blue"
          },
          StandardLabelPlacementProperties = new CIMStandardLabelPlacementProperties
          {
            AllowOverlappingLabels = true,
            LineOffset = 1.0
          },
          MaplexLabelPlacementProperties = new CIMMaplexLabelPlacementProperties
          {
            AlignLabelToLineDirection = true,
            AvoidPolygonHoles = true
          }
        };
    
        // Create a list of labels
        List<CIMLabelClass> labelClasses = new List<CIMLabelClass> { greenLabelClass, blueLabelClass };
    
    
        // Create linked feature description
        // Linked feature class name
        string linkedFeatureClassName = "WaterPipe";
    
        // Create fields for water pipe
        FieldDescription waterPipeGlobalID = FieldDescription.CreateGlobalIDField();
        FieldDescription pipeName = FieldDescription.CreateStringField("PipeName", 255);
    
        // Create a list of water pipe field descriptions
        List<FieldDescription> pipeFieldDescriptions = new List<FieldDescription> { waterPipeGlobalID, pipeName };
    
        // Create a linked feature class description
        FeatureClassDescription linkedFeatureClassDescription = new FeatureClassDescription(linkedFeatureClassName,
          pipeFieldDescriptions,
          new ShapeDescription(GeometryType.Polyline, spatialReference));
    
        // Create a SchemaBuilder object
        SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
    
        // Add the creation of the linked feature class to the list of DDL tasks
        FeatureClassToken linkedFeatureClassToken = schemaBuilder.Create(linkedFeatureClassDescription);
    
        // Create an annotation feature class description object to describe the feature class to create
        AnnotationFeatureClassDescription annotationFeatureClassDescription =
          new AnnotationFeatureClassDescription(annotationFeatureClassName, fieldDescriptions, shapeDescription,
            generalPlacementProperties, labelClasses, new FeatureClassDescription(linkedFeatureClassToken))
          {
            IsAutoCreate = true,
            IsSymbolIDRequired = false,
            IsUpdatedOnShapeChange = true
          };
    
        // Add the creation of the annotation feature class to the list of DDL tasks
        schemaBuilder.Create(annotationFeatureClassDescription);
    
        // Execute the DDL
        bool success = schemaBuilder.Build();
    
        // Inspect error messages
        if (!success)
        {
          IReadOnlyList<string> errorMessages = schemaBuilder.ErrorMessages;
          //etc.
        }
      });
    }
    Creating an annotation feature class inside feature dataset
    {
      Task CreateAnnotationFeatureClassUsingExistingAnnotationFeatureClassInDatasetAsync(
        Geodatabase geodatabase) => QueuedTask.Run(() =>
      {
        // Create a Cities annotation feature class inside Places feature dataset using existing annotation feature class
    
        // Feature dataset name
        string featureDatasetName = "Places";
    
        // Annotation feature class name
        string annotationFeatureClassName = "CitiesAnnotation";
    
        // Create a SchemaBuilder object
        SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
    
        // Open existing annotation feature class name
        using (AnnotationFeatureClass existingAnnotationFeatureClass = geodatabase.OpenDataset<AnnotationFeatureClass>("ExistingAnnotationFeatureClass"))
        {
          // Create Feature dataset description
          FeatureDatasetDescription featureDatasetDescription = new FeatureDatasetDescription(featureDatasetName, existingAnnotationFeatureClass.GetDefinition().GetSpatialReference());
    
          // Add the creation of the Places dataset to DDL task
          FeatureDatasetToken featureDatasetToken = schemaBuilder.Create(featureDatasetDescription);
    
          // Create an annotation feature class description using existing annotation feature class
          AnnotationFeatureClassDescription annotationFeatureClassDescription = new AnnotationFeatureClassDescription(annotationFeatureClassName,
              existingAnnotationFeatureClass.GetDefinition())
          {
            IsAutoCreate = true,
            IsSymbolIDRequired = false,
            IsUpdatedOnShapeChange = true
          };
    
          // Add the creation of the Cities annotation feature class inside Places feature dataset
          schemaBuilder.Create(new FeatureDatasetDescription(featureDatasetToken),
            annotationFeatureClassDescription);
    
          // Execute the DDL
          bool success = schemaBuilder.Build();
    
          // Inspect error messages
          if (!success)
          {
            IReadOnlyList<string> errorMessages = schemaBuilder.ErrorMessages;
            //etc.
          }
        }
      });
    }
    Creating a dimension feature class
    {
      Task CreateDimensionFeatureClassAsync(Geodatabase geodatabase) => QueuedTask.Run(() =>
      {
        // Dimension feature class name
        string dimensionFeatureClassName = "LineInfo";
    
        // Create user defined attribute fields for dimension feature class
        FieldDescription nameFieldDescription = new FieldDescription("Name", FieldType.String);
        FieldDescription distanceFieldDescription = new FieldDescription("DistanceMeasure", FieldType.Double);
        FieldDescription measurementDateFieldDescription = new FieldDescription("MeasurementDate", FieldType.Date);
    
        // Create a list of all field descriptions
        List<FieldDescription> fieldDescriptions = new List<FieldDescription>
            { nameFieldDescription, distanceFieldDescription, measurementDateFieldDescription };
    
        // Create a ShapeDescription object
        ShapeDescription shapeDescription = new ShapeDescription(GeometryType.Polygon, SpatialReferences.WGS84);
    
        // Create a SchemaBuilder object
        SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
    
        // Create DimensionFeatureClassDescription object
        DimensionFeatureClassDescription dimensionFeatureClassDescription = new DimensionFeatureClassDescription(
          dimensionFeatureClassName, fieldDescriptions,
          shapeDescription, GetCIMDimensionStyles());
    
        // Token
        DimensionFeatureClassToken dimensionFeatureClassToken =
          schemaBuilder.Create(dimensionFeatureClassDescription);
    
        // Execute the DDL
        bool success = schemaBuilder.Build();
    
        // Inspect error messages
        if (!success)
        {
          IReadOnlyList<string> errorMessages = schemaBuilder.ErrorMessages;
          //etc.
        }
    
        List<CIMDimensionStyle> GetCIMDimensionStyles()
        {
          CIMColor color = CIMColor.CreateRGBColor(10, 20, 30);
          CIMPointSymbol beginMarkerSymbol = GetMarkerSymbol(color);
          CIMPointSymbol endMarkerSymbol = GetMarkerSymbol(color);
          CIMLineSymbol dimensionLineSymbol = GetLineSymbol(color, 0.5);
          CIMLineSymbol extensionLineSymbol = GetLineSymbol(color, 0.5);
          CIMTextSymbol textSymbol = GetDefaultTextSymbol(10);
          textSymbol.Symbol = GetPolygonSymbol(color, color, 0);
          textSymbol.HorizontalAlignment = HorizontalAlignment.Center;
    
          CIMDimensionStyle cimDimensionStyle = new CIMDimensionStyle()
          {
            Name = "Style 1",
            ID = 0,
            Align = true,
            DisplayUnits = null,
            DisplayPrecision = 0,
    
            BeginMarkerSymbol = beginMarkerSymbol,
            EndMarkerSymbol = endMarkerSymbol,
            MarkerOption = DimensionPartOptions.Both,
            MarkerFit = DimensionMarkerFit.Text,
    
            DimensionLineSymbol = dimensionLineSymbol,
            DimensionLineOption = DimensionPartOptions.Both,
            DrawLineOnFit = false,
            ExtendLineOnFit = true,
    
            BaselineHeight = 0.0,
            ExtensionLineSymbol = extensionLineSymbol,
            ExtensionLineOption = DimensionPartOptions.Both,
            ExtensionLineOvershot = 0.0,
            ExtensionLineOffset = 0.0,
    
            Expression = "",
            ExpressionParserName = "Arcade",
    
            TextSymbol = textSymbol,
            TextOption = DimensionTextOption.Only,
            TextFit = DimensionTextFit.MoveBegin,
          };
    
          List<CIMDimensionStyle> cimDimensionStyles = [cimDimensionStyle];
    
          return cimDimensionStyles;
        }
    
        CIMFill DefaultFill(CIMColor color)
        {
          return new CIMSolidFill()
          {
            Enable = true,
            Name = "Fill_" + Guid.NewGuid().ToString(),
            ColorLocked = false,
            Color = color
          };
        }
    
        CIMStroke DefaultStroke(CIMColor color, double width = 1)
        {
          return new CIMSolidStroke()
          {
            Color = color,
            Name = "Stroke_" + Guid.NewGuid().ToString(),
            CapStyle = LineCapStyle.Round,
            JoinStyle = LineJoinStyle.Round,
            CloseCaps3D = false,
            LineStyle3D = Simple3DLineStyle.Strip,
            MiterLimit = 4,
            Width = width,
    
            ColorLocked = false,
            Enable = true,
          };
        }
    
        CIMPolygonSymbol GetPolygonSymbol(CIMColor fillColor, CIMColor outlineColor, double outlineWidth)
        {
          if ((outlineColor == null) || (outlineWidth <= 0))
          {
            return new CIMPolygonSymbol() { SymbolLayers = new CIMSymbolLayer[1] { DefaultFill(fillColor) } };
          }
    
          return new CIMPolygonSymbol()
          {
            SymbolLayers = new CIMSymbolLayer[2]
              { DefaultStroke(outlineColor, outlineWidth), DefaultFill(fillColor) }
          };
        }
    
        CIMLineSymbol GetLineSymbol(CIMColor color, double width)
        {
          CIMStroke stroke = DefaultStroke(color, width);
    
          return new CIMLineSymbol() { SymbolLayers = new CIMSymbolLayer[1] { stroke } };
        }
    
        Polygon CreateArrowGeometry()
        {
          double x = 2.39;
          double y = 1.20;
          double xMod = 0.3;
    
          Coordinate2D pt1 = new Coordinate2D() { X = -x + xMod, Y = -y };
          Coordinate2D pt2 = new Coordinate2D() { X = x + xMod, Y = 0 };
          Coordinate2D pt3 = new Coordinate2D() { X = -x + xMod, Y = y };
          List<Coordinate2D> coords = new List<Coordinate2D>() { pt1, pt2, pt3 };
    
          Polygon polygon = PolygonBuilderEx.CreatePolygon(coords);
          return polygon;
        }
    
        CIMPointSymbol GetMarkerSymbol(CIMColor color)
        {
          CIMMarkerGraphic graphic = new CIMMarkerGraphic()
          {
            Geometry = CreateArrowGeometry(),
            Symbol = new CIMPolygonSymbol()
            {
              SymbolLayers = new CIMSymbolLayer[1]
              {
                  new CIMSolidFill()
                  {
                    Enable = true,
                    Color = color,
                  }
              },
              UseRealWorldSymbolSizes = false
            }
          };
    
          CIMSymbolLayer symbolLayer = new CIMVectorMarker()
          {
            Enable = true,
            Size = 12,
            Frame = new EnvelopeBuilderEx() { XMin = -5, YMin = -3, XMax = 5, YMax = 3 }.ToGeometry() as Envelope,
            MarkerGraphics = new CIMMarkerGraphic[1] { graphic },
            ScaleSymbolsProportionally = true,
            RespectFrame = true
          };
    
          return new CIMPointSymbol()
          {
            SymbolLayers = new CIMSymbolLayer[1] { symbolLayer },
            HaloSize = 1,
            ScaleX = 1,
            AngleAlignment = AngleAlignment.Map,
          };
        }
    
        CIMTextSymbol GetDefaultTextSymbol(double height)
        {
          return new CIMTextSymbol()
          {
            DrawGlyphsAsGeometry = false,
            DrawSoftHyphen = false,
            ExtrapolateBaselines = true,
            FlipAngle = 0.0,
            IndentAfter = 0.0,
            IndentBefore = 0.0,
            IndentFirstLine = 0.0,
            Kerning = true,
            LetterSpacing = 0.0,
            LetterWidth = 100.0,
            Ligatures = true,
            LineGap = 0.0,
            LineGapType = LineGapType.ExtraLeading,
            Underline = false,
            Strikethrough = false,
            OffsetX = 0.0,
            OffsetY = 0.0,
            FontFamilyName = "Tahoma",
            FontStyleName = "Regular",
            WordSpacing = 100.0,
            Height = height
          };
        }
      });
    }
    Creating the memory geodatabase
    {
      await QueuedTask.Run(() =>
      {
        // Creates the default memory geodatabase if not exist or connects to an existing one if already exists
        Geodatabase memoryGeodatabase = new Geodatabase(new MemoryConnectionProperties());
    
        // Creates schema
        SchemaBuilder schemaBuilder = new SchemaBuilder(memoryGeodatabase);
        schemaBuilder.Create(new TableDescription("MyTable", new List<FieldDescription>()));
        schemaBuilder.Build();
    
        return memoryGeodatabase;
      });
    }
    Creating a table with index from scratch
    {
      Task CreatingTableWithIndexAsync(SchemaBuilder schemaBuilder) => QueuedTask.Run(() =>
      {
        FieldDescription nameFieldDescription = FieldDescription.CreateStringField("Name", 50);
        FieldDescription addressFieldDescription = FieldDescription.CreateStringField("Address", 200);
    
        // Creating a feature class, 'Buildings' with two fields
        TableDescription tableDescription = new TableDescription("Buildings",
          new List<FieldDescription>() { nameFieldDescription, addressFieldDescription });
    
        // Enqueue DDL operation to create a table
        TableToken tableToken = schemaBuilder.Create(tableDescription);
    
        // Creating an attribute index named as 'Idx'
        AttributeIndexDescription attributeIndexDescription = new AttributeIndexDescription("Idx", new TableDescription(tableToken),
          new List<string> { nameFieldDescription.Name, addressFieldDescription.Name });
    
        // Enqueue DDL operation to create an attribute index
        schemaBuilder.Create(attributeIndexDescription);
    
        // Execute build indexes operation
        bool isBuildSuccess = schemaBuilder.Build();
      });
    }
    Adding indexes in pre-existing dataset
    {
      Task AddingIndexesAsync(SchemaBuilder schemaBuilder, FeatureClassDefinition featureClassDefinition) => QueuedTask.Run(() =>
      {
        // Field names to add in the attribute index
        string fieldName = featureClassDefinition.GetFields().First(f => f.AliasName.Contains("Name")).Name;
        string fieldAddress = featureClassDefinition.GetFields().First(f => f.AliasName.Contains("Address")).Name;
    
        // Creating an attribute index with index name 'Idx' and two participating fields' name
        AttributeIndexDescription attributeIndexDescription = new AttributeIndexDescription("Idx",
          new TableDescription(featureClassDefinition), new List<string> { fieldName, fieldAddress });
    
        // Enqueue DDL operation for an attribute index creation
        schemaBuilder.Create(attributeIndexDescription);
    
        // Creating the spatial index
        SpatialIndexDescription spatialIndexDescription = new SpatialIndexDescription(new FeatureClassDescription(featureClassDefinition));
    
        // Enqueue DDL operation for the spatial index creation
        schemaBuilder.Create(spatialIndexDescription);
    
        // Execute build indexes operation
        bool isBuildSuccess = schemaBuilder.Build();
    
        if (!isBuildSuccess)
        {
          IReadOnlyList<string> errors = schemaBuilder.ErrorMessages;
          // Iterate and handle errors
        }
      });
    }
    Removing attribute index
    {
      Task RemoveAttributeIndexAsync(SchemaBuilder schemaBuilder, FeatureClassDefinition featureClassDefinition, string attributeIndexName) => QueuedTask.Run(() =>
      {
        // Find a index to be removed
        ArcGIS.Core.Data.Index indexToRemove = featureClassDefinition.GetIndexes().First(f => f.GetName().Equals(attributeIndexName));
    
        // Index description of the index to be removed
        AttributeIndexDescription indexDescriptionToRemove = new AttributeIndexDescription(indexToRemove, new TableDescription(featureClassDefinition));
    
        // Enqueue the DDL operation to remove index
        schemaBuilder.Delete(indexDescriptionToRemove);
    
        // Execute the delete index operation
        bool isDeleteIndexSuccess = schemaBuilder.Build();
      });
    }
    Removing spatial index
    {
      Task RemoveSpatialIndexAsync(SchemaBuilder schemaBuilder, FeatureClassDefinition featureClassDefinition) => QueuedTask.Run(() =>
      {
        // Create a spatial description
        SpatialIndexDescription spatialIndexDescription = new SpatialIndexDescription(new FeatureClassDescription(featureClassDefinition));
    
        // Enqueue the DDL operation to remove index
        schemaBuilder.Delete(spatialIndexDescription);
    
        // Execute the delete index operation
        bool isDeleteIndexSuccess = schemaBuilder.Build();
      });
    }
    Modifying domain
    {
      Task ModifyDomainAsync(Geodatabase geodatabase, string codedValueDomainName = "Pipe") => QueuedTask.Run(() =>
      {
        SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
        CodedValueDomain codedValueDomain = geodatabase.GetDomains().First(f => f.GetName().Equals(codedValueDomainName)) as CodedValueDomain;
        CodedValueDomainDescription codedValueDomainDescription = new CodedValueDomainDescription(codedValueDomain);
    
        // Update domain description
        codedValueDomainDescription.Description = "Water Pipe Domain";
    
        // Adding code/value pair
        codedValueDomainDescription.CodedValuePairs.Add("C", "Copper");
    
        schemaBuilder.Modify(codedValueDomainDescription);
    
        // To modify the orders of coded value domain
        // schemaBuilder.Modify(codedValueDomainDescription,SortBy.Name,SortOrder.Ascending);
    
        schemaBuilder.Build();
      });
    }
    Rename domain
    {
      Task RenameDomainAsync(Geodatabase geodatabase, string rangeDomainOldName = "PipeDiameter", string rangeDomainNewName = "PipeDiam") => QueuedTask.Run(() =>
      {
        SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
        RangeDomain rangeDomain = geodatabase.GetDomains().First(f => f.GetName().Equals(rangeDomainOldName)) as RangeDomain;
    
        // Renaming a domain
        schemaBuilder.Rename(new RangeDomainDescription(rangeDomain), rangeDomainNewName);
        schemaBuilder.Build();
      });
    }
    Delete domain
    {
      Task DeleteDomainAsync(Geodatabase geodatabase, string domainNameToBeDeleted = "PipeMaterial") => QueuedTask.Run(() =>
      {
        SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
        CodedValueDomain codedValueDomain = geodatabase.GetDomains().First(f => f.GetName().Equals(domainNameToBeDeleted)) as CodedValueDomain;
        CodedValueDomainDescription codedValueDomainDescription = new CodedValueDomainDescription(codedValueDomain);
    
        // Deleting a coded value domain
        schemaBuilder.Delete(codedValueDomainDescription);
        schemaBuilder.Build();
      });
    }
    Creating table with subtypes
    {
      Task CreateTableWithSubtypesAsync(SchemaBuilder schemaBuilder) => QueuedTask.Run(() =>
      {
        // Creating a 'Building' table with the subtype field 'BuildingType'
        FieldDescription buildingType = new FieldDescription("BuildingType", FieldType.Integer);
        FieldDescription buildingName = new FieldDescription("Name", FieldType.String);
    
        TableDescription tableDescription = new TableDescription("Building", new List<FieldDescription> { buildingName, buildingType });
    
        // Add the building type subtype with three subtypes - Business, Marketing, Security
        tableDescription.SubtypeFieldDescription = new SubtypeFieldDescription(buildingType.Name,
          new Dictionary<int, string> { { 1, "Business" }, { 2, "Marketing" }, { 3, "Security" } })
        {
          DefaultSubtypeCode = 3 // Assigning 'Security' building type as the default subtype
        };
    
        schemaBuilder.Create(tableDescription);
        schemaBuilder.Build();
      });
    }
    Removing subtype field designation
    {
      Task DeleteSubtypeFieldAsync(SchemaBuilder schemaBuilder, FeatureClassDefinition featureClassDefinition) => QueuedTask.Run(() =>
      {
        FeatureClassDescription featureClassDescription = new FeatureClassDescription(featureClassDefinition);
    
        // Set subtype field to null to remove the subtype field designation
        featureClassDescription.SubtypeFieldDescription = null;
    
        schemaBuilder.Modify(featureClassDescription);
        schemaBuilder.Build();
      });
    }
    Modifying subtypes
    {
      Task ModifySubtypesAsync(SchemaBuilder schemaBuilder, TableDefinition tableDefinition) => QueuedTask.Run(() =>
      {
        TableDescription tableDescription = new TableDescription(tableDefinition);
    
        // Remove the first subtype from the table
        IReadOnlyList<Subtype> subtypes = tableDefinition.GetSubtypes();
        tableDescription.SubtypeFieldDescription.Subtypes.Remove(subtypes.First().GetCode());
    
        // Adding a new subtype, 'Utility', in the existing table
        tableDescription.SubtypeFieldDescription.Subtypes.Add(4, "Utility");
    
        // Assigning 'Utility' subtype as the default subtype
        tableDescription.SubtypeFieldDescription.DefaultSubtypeCode = 4;
    
        schemaBuilder.Modify(tableDescription);
        schemaBuilder.Build();
      });
    }
    Creating relationship class
    {
      Task CreateRelationshipWithRelationshipRulesAsync(SchemaBuilder schemaBuilder) => QueuedTask.Run(() =>
      {
        // 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);
        FieldDescription usageSubType = FieldDescription.CreateIntegerField("UsageSubtype");
        FeatureClassDescription featureClassDescription = new FeatureClassDescription("Building",
          new List<FieldDescription> { buildingId, buildingAddress, buildingType, usageSubType },
          new ShapeDescription(GeometryType.Polygon, SpatialReferences.WGS84));
    
        // Set subtype details (optional)
        featureClassDescription.SubtypeFieldDescription = new SubtypeFieldDescription(usageSubType.Name,
          new Dictionary<int, string> { { 1, "Marketing" }, { 2, "Utility" } });
    
        FeatureClassToken buildingToken = schemaBuilder.Create(featureClassDescription);
    
        // Creating a 1:M relationship between the 'Building' feature class and 'BuildingType' table
        RelationshipClassDescription relationshipClassDescription = new RelationshipClassDescription(
          "BuildingToBuildingType", new FeatureClassDescription(buildingToken), new TableDescription(buildingtypeToken),
          RelationshipCardinality.OneToMany, buildingType.Name, buildingType.Name)
        {
          RelationshipType = RelationshipType.Composite
        };
    
        // Adding relationship rules for the 'Marketing' subtype
        relationshipClassDescription.RelationshipRuleDescriptions.Add(new RelationshipRuleDescription(1, null));
    
        schemaBuilder.Create(relationshipClassDescription);
        schemaBuilder.Build();
      });
    }
    Creating attributed relationship class
    {
      Task CreateAttributedRelationshipAsync(SchemaBuilder schemaBuilder) => QueuedTask.Run(() =>
      {
        // 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();
      });
    }
    Add relationship rules to a relationship class
    {
      Task ModifyRelationshipClassAsync(SchemaBuilder schemaBuilder, AttributedRelationshipClassDefinition attributedRelationshipClassDefinition) => QueuedTask.Run(() =>
      {
        AttributedRelationshipClassDescription attributedRelationshipClassDescription = new AttributedRelationshipClassDescription(attributedRelationshipClassDefinition);
    
        // Update the relationship split policy
        attributedRelationshipClassDescription.RelationshipSplitPolicy = RelationshipSplitPolicy.UseDefault;
    
        // Add field in the intermediate table
        attributedRelationshipClassDescription.FieldDescriptions.Add(FieldDescription.CreateIntegerField("RelationshipStatus"));
    
        // Add relationship rules based on subtypes,if available
        // Assuming origin class has subtype with code 1
        attributedRelationshipClassDescription.RelationshipRuleDescriptions.Add(
          new RelationshipRuleDescription(1, null));
    
        // Enqueue modify operation
        schemaBuilder.Modify(attributedRelationshipClassDescription);
    
        // Execute modify DDL operation
        schemaBuilder.Build();
      });
    }
    Deleting a relationship class
    {
      Task DeleteRelationshipClassAsync(SchemaBuilder schemaBuilder, RelationshipClassDefinition relationshipClassDefinition) => QueuedTask.Run(() =>
      {
        schemaBuilder.Delete(new RelationshipClassDescription(relationshipClassDefinition));
        schemaBuilder.Build();
      });
    }
    Adding/Removing Relationship class in/out of a feature dataset
    {
      Task MoveRelationshipClassAsync(SchemaBuilder schemaBuilder, FeatureDatasetDefinition featureDatasetDefinition, RelationshipClassDefinition relationshipClassDefinition) => QueuedTask.Run(() =>
      {
        FeatureDatasetDescription featureDatasetDescription = new FeatureDatasetDescription(featureDatasetDefinition);
        RelationshipClassDescription relationshipClassDescription = new RelationshipClassDescription(relationshipClassDefinition);
    
        // Remove relationship class from the feature dataset
        schemaBuilder.RemoveRelationshipClass(featureDatasetDescription, relationshipClassDescription);
    
        // Add relationship class inside the feature dataset
        // schemaBuilder.AddRelationshipClass(featureDatasetDescription, relationshipClassDescription);
    
        schemaBuilder.Build();
      });
    }
    Modifying annotation labels and symbols
    {
      Task ModifyAnnotationLabelAndSymbolsAsync(SchemaBuilder schemaBuilder, AnnotationFeatureClassDefinition annotationFeatureClassDefinition) => QueuedTask.Run(() =>
      {
        AnnotationFeatureClassDescription annotationFeatureClassDescription = new AnnotationFeatureClassDescription(annotationFeatureClassDefinition);
        IReadOnlyList<CIMLabelClass> labelClasses = annotationFeatureClassDescription.LabelClasses;
    
        // Adding a new annotation label class
        List<CIMLabelClass> modifiedLabelClasses = new List<CIMLabelClass>(labelClasses);
        modifiedLabelClasses.Add(new CIMLabelClass()
        {
          Name = "RedSymbol",
          TextSymbol = new CIMSymbolReference
          {
            Symbol = new CIMTextSymbol()
            {
              Angle = 45,
              FontType = FontType.Type1,
              FontFamilyName = "Arial",
              FontEffects = FontEffects.Normal,
              HaloSize = 2.0,
    
              Symbol = new CIMPolygonSymbol
              {
                SymbolLayers = new CIMSymbolLayer[]
                  { new CIMSolidFill { Color = CIMColor.CreateRGBColor(255, 0, 0) } },
                UseRealWorldSymbolSizes = true
              }
            },
            MaxScale = 0,
            MinScale = 0,
            SymbolName = "TextSymbol-RED"
          }
        });
    
        // Adding a  new symbol
        annotationFeatureClassDescription.Symbols.Add(new CIMSymbolIdentifier()
        {
          ID = 1001,
          Name = "ID_10001",
          Symbol = new CIMTextSymbol()
          {
            Angle = 43,
            FontEffects = FontEffects.Subscript,
            FontType = FontType.TTOpenType,
            FontStyleName = "Regular",
            FontFamilyName = "Tahoma",
            TextCase = TextCase.Allcaps
          }
        });
    
        // Modify annotation feature class
        AnnotationFeatureClassDescription modifiedAnnotationFeatureClassDescription = new AnnotationFeatureClassDescription(annotationFeatureClassDescription.Name,
            annotationFeatureClassDescription.FieldDescriptions, annotationFeatureClassDescription.ShapeDescription,
            annotationFeatureClassDescription.GeneralPlacementProperties, modifiedLabelClasses);
    
        // Enqueue modify
        schemaBuilder.Modify(modifiedAnnotationFeatureClassDescription);
    
        // DDL execute
        schemaBuilder.Build();
      });
    }
    Rename annotation feature class
    {
      Task RenameAsync(SchemaBuilder schemaBuilder, AnnotationFeatureClassDefinition annotationFeatureClassDefinition, string featureClassNewName) => QueuedTask.Run(() =>
      {
        AnnotationFeatureClassDescription annotationFeatureClassDescription = new AnnotationFeatureClassDescription(annotationFeatureClassDefinition);
    
        // Enqueue rename operation
        schemaBuilder.Rename(annotationFeatureClassDescription, featureClassNewName);
    
        // Execute DDL
        schemaBuilder.Build();
      });
    }
    Modifying an existing field
    {
      Task ModifyExistingFieldAsync(SchemaBuilder schemaBuilder, TableDefinition tableDefinition, string fieldNameToBeModified = "PropertyAddress") => QueuedTask.Run(() =>
      {
        Field field = tableDefinition.GetFields().FirstOrDefault(f => f.Name.Contains(fieldNameToBeModified));
    
        // Update field's alias name and length
        FieldDescription fieldDescription = new FieldDescription(field)
        {
          AliasName = "Physical Property Address",
          Length = 50
        };
    
        // Update the default value
        fieldDescription.SetDefaultValue("123 Main St");
    
        // Enqueue modify operation
        schemaBuilder.Modify(new TableDescription(tableDefinition), field.Name, fieldDescription);
    
        // Execute DDL
        schemaBuilder.Build();
      });
    }
    Create a routes feature class using the DDL
    {
      static void CreateRoutes(SchemaBuilder schemaBuilder)
      {
        FieldDescription routeIdDescription = FieldDescription.CreateIntegerField("RouteID");
        FieldDescription routeNameDescription = FieldDescription.CreateStringField("RouteName", 100);
        ShapeDescription shapeDescription = new ShapeDescription(GeometryType.Polyline, SpatialReferences.WGS84)
        {
          HasM = true,
          HasZ = false
        };
    
        FeatureClassDescription routeFeatureClassDescription = new FeatureClassDescription("Routes",
          new List<FieldDescription>() { routeIdDescription, routeNameDescription }, shapeDescription);
    
        //Create an M-enabled poly-line feature class
        schemaBuilder.Create(routeFeatureClassDescription);
        schemaBuilder.Build();
      }
    }
    Create an events table using the DDL
    {
      static void CreateEvents(SchemaBuilder schemaBuilder)
      {
        FieldDescription routeIdDescription = FieldDescription.CreateIntegerField("RID");
        FieldDescription measureFieldDescription = new FieldDescription("Measure", FieldType.Double);
        FieldDescription offsetFieldDescription = FieldDescription.CreateIntegerField("OffsetValue");
    
        TableDescription eventTableDescription = new TableDescription("LR_EventTable",
          new List<FieldDescription>() { routeIdDescription, offsetFieldDescription, measureFieldDescription });
    
        schemaBuilder.Create(eventTableDescription);
        schemaBuilder.Build();
      }
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also