I have a simple data model: a parent entity in an optional one-to-many relationship with a child entity. The inverse relationship (child -> parent) is mandatory (non-optional).
After a child object is deleted, Core Data refuses to save, complaining about a missing required property in the child entity. The error goes away if the inverse relationship is made optional.
Why can I not have a mandatory inverse relationship where it is logical (i.e. a child must have a parent)? Why Core Data complains about a deleted object's inconsistency? Is this expected behaviour?
Thank you for any clarifications.
Edit: As requested, I am including a picture of my test data model:
As for the question about delete code, there is none. It's all done through NSArrayController
bindings set up in the application window nib. You can load the test project here: Parent-child test project. It should probably be mentioned that this project is based on NSPersistentDocument
architecture.
The behaviour I observe is as follows: if a parent is created without children, the document can be normally saved. If a child is created and then deleted, there is an error message on trying to save the document: