Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

Please give me any help or advice.

share|improve this question
add comment

1 Answer 1

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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