I want to delete some fields of featureclasses, but when I run the code FeatureClass.DeleteField(Field) it works well for some featureclasses but after some time it gives an error such as:

The field cannot be deleted because it is being used as a relationship key.


The layers where this error is occurring must be a part of a Relationship Class.

In ArcGIS, this is a join between two feature classes or tables that is being maintained by the Geodatabase. It can be either a one to one, one to many or many to many relationship. It is based on Primary and Foreign key fields, which contain unique identifiers to link the tables together. Since the Relationship Class is a type of object maintained by the geodatabase, the Key fields are properties of this class and are likely going to be protected from deletion.

What you will need to do to solve this problem is make a list of those feature classes where an error is being raised, and find the relationship class or classes associated with them. You will have to delete those relationship classes in order for the lock to be removed from the particular field in the feature class.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.