Hi,
I wrote code that adds a field to a feature class using SchemaBuilder. It works correctly with a file geodatabase, but not with an enterprise geodatabase hosted on PostgreSQL. In that case, an error message is returned stating: "The Fields collection contained multiple geometry fields. (st_perimeter(shape)".
The error occurs regardless of the geometry storage mode (PostGIS or ST_Geometry).
var featureClass = featureLayer.GetFeatureClass();
using (var geodatabase = featureClass.GetDatastore() as Geodatabase)
{
var fcDefinition = featureClass.GetDefinition();
var fcDescription = new FeatureClassDescription(fcDefinition);
var fieldDescription = ArcGIS.Core.Data.DDL.FieldDescription.CreateStringField("NEW_FIELD", 50);
var newFcDescription = new List<ArcGIS.Core.Data.DDL.FieldDescription>(fcDescription.FieldDescriptions);
newFcDescription.Add(fieldDescription);
FeatureClassDescription newDesc = new FeatureClassDescription(fcDescription.Name, newFcDescription, fcDescription.ShapeDescription);
var schemaBuilder = new SchemaBuilder(geodatabase);
schemaBuilder.Modify(newDesc);
bool res = schemaBuilder.Build();
if (res)
MessageBox.Show("Field added");
else
MessageBox.Show(schemaBuilder.ErrorMessages.First().ToString());
}Is this a known issue or an expected behavior? Is there a different way of adding a field with the SDK when working with an enterprise geodatabase?
Thanks for your help.
Which version of ArcGIS Pro are you using? I'd like to see if I can replicate the issue on our end.
ArcGIS Pro version: 3.6.4 PostgreSQL version: 13.8
But I wonder if the problem might simply stem from a compatibility issue with the st_geometry library.