I have the following data model and i want to break the many-to-many relationship between EntityA and EntityB. I'm doing this by removing EntityC object that connects both of them. I found that EntityA still have a relationship with EntityB although I saved the managed object context, I can see the changes take affect after EntityA records are re-fetched from database. Is there something I'm missing? Thanks in advance,Sarah
1 Answers
I agree with the comment from Barry, from your description it sounds like you are using more than one NSManagedObjectContext
and that will definitely cause an issue.
Is this a multi-threaded application?
Did you base this off of one of the Apple examples?
update
Referental integrity is the mostly likely cause of this issue. When you delete A, the relationship to C, from C's point of view may not be cleared immediately because Core Data does that kind of clean up either at the end of the run loop or at the next save. This means if you are peeking at the value before either of those occur, the relationship may be there. Are you look at the relationship immediately or is it hanging around a while late, i.e. after a save?
update
In your original question you stated that after the save EntityA still has a relationship to EntityB. Is this a typo? According to your model EntityA and EntityB do not have a direct relationship. Can you clarify?
or perhaps show the code where you delete EntityC and where you see EntityA having a relationship with EntityB.
NSManagedObjectContext
s. – Barry Wark