Uniqueness with to-one mandatory inverse relationship

Why entity cannot have uniqueness constraints with to-one mandatory inverse relationship?

Having two entities:


- Person

property: name

relationship: department (to-one, non-optional)


- Department

property: title (unique constraint)

relationship: person (to-many, optional)


Model won't compile in iOS 9, XCode 7.0.1 with misconfigured entity error:

Misconfigured Entity: Entity Department cannot have uniqueness constraints and to-one mandatory inverse relationship Person.department

I have the exact same setup and the exact same problem! I don’t understand why Core Data won’t allow this. 😟

Were you able to figure it out?

I have the same problem with Xcode 7.2. I'd really like to know wether this is simply a bug or a limitation imposed for any specific reason and, in that case, what the reason is...


I've not found anything related to this in the documentation.

any updates on this item?

Have the same problem. And I was surprised that google show me nothing about this problem. Are other developers doesn't use unique constraints? Or how they deals with this problem?

This is my question on Stackoverflow:

http://stackoverflow.com/questions/37546213/coredata-uniqueness-constraints-and-to-one-mandatory-inverse-relationship


I'm expecting somebody from Apple explain how to deal with it.

The SO post doesn't have an answer... Have you been able to resolve this? I'm having the same problem.

Unique Constraints conflicts are like merge conflicts, they are not SQL unique indexes as you would expect, more info here:


http://dorianroy.com/blog/2015/09/how-to-implement-unique-constraints-in-core-data-with-ios-9/


So because of how merge handling works, in that it can wipe a record clean, it isn't possible to enforce an optional validation at that stage. Or maybe it was too hard for them to implement?

If you delete the affected entity and recreate it, the error fixes.

Uniqueness with to-one mandatory inverse relationship
 
 
Q