AnsweredAssumed Answered

Inserting GUIDs into a file geodatabase

Question asked by CARNELL_DEV2 on Jul 6, 2020
Latest reply on Jul 7, 2020 by CARNELL_DEV2

I am reading data from a database that is incompatible with ArcGIS Pro into an ESRI geodatabase using the .Net SDK. The database stores primary keys as GUIDs e.g. {e372ad91-9e24-4054-9454-5bb31657f2db} which is the same format as a GUID field in an ESRI file geodatabase (.gdb).

 

However, if I try to write these GUIDs to a file geodatabase, I get an exception at the line where I add the GUID field to the row buffer:

NameValueType
$exception{"A general error when something is wrong with a Field."}ArcGIS.Core.Data.GeodatabaseFieldException

 

Are GUIDs in file geodatabases handled in a special way? I can't seem to write in new ones generated outside of ArcGIS Pro. 

 

Thank you very much in advance.

 

Here is the basic outline of my code and a mock feature table to illustrate my question:

FacilityIDNameOwnTypeGUIDField
1Griffith ParkMunicipal{e372ad91-9e24-4054-9454-5bb31657f2db}
2LondonMunicipal{zyxqad91-7g76-9999-9434-5aa31657f2db}
3IndiaMunicipal{abc1ad91-9e24-8888-1234-5aa12345f2db}

 

public async Task CreatingAFeature() {   
         string message = String.Empty;  
         bool creationResult = false;   

         await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
         {    
            using (Geodatabase geodatabase = new Geodatabase(new Geodatabase(new FileGeodatabaseConnectionPath(new Uri("filePath")));))))    
            using (FeatureClass featureClass = geodatabase.OpenDataset<FeatureClass>("FeatureClassName"))    
            {             
               //declare the callback      
               EditOperation editOperation = new EditOperation();      
               editOperation.Callback(context =>
               {        
               FeatureClassDefinition facilitySiteDefinition = featureClass.GetDefinition();        
               int facilityIdIndex = facilitySiteDefinition.FindField("FACILITYID");         
               using (RowBuffer rowBuffer = featureClass.CreateRowBuffer())        
               {          
                  // Fill fields of row buffer         
               rowBuffer["facilityId"] = 4;          
               rowBuffer["NAME"] = "Griffith Park";          
               rowBuffer["OWNTYPE"] = "Municipal";
         
                /* The line that throws the exception.
                Commenting out this line makes everything run fine
                I generate a new GUID here for the sake of the example.
                Trying to write a GUID from the dataset, or writing the GUID
                as a string also throws an exception.
                */

                rowBuffer["GUIDField"] = Guid.NewGuid();  // The line that throws the exception.            

          ... code continues

Outcomes