Note that there are some explanatory texts on larger screens.

plurals
  1. PONSManagedObject Entity Inheritance causes NSInternalInconsistencyException
    primarykey
    data
    text
    <p>I have an NSManagedObject ElementA with several attributes that should exist in ElementB through a parent-child relationship. When setting ElementA as the Parent Entity to ElementB, the NSPersistentStoreCoordinator fails. The ManagedObjectModel is correctly being built, and the entities/classes work separate of each other. The only difference between the app failing and compiling is this parent-child relationship. None of the attributes from either entity overlap.</p> <p>I don't have enough rep yet, so the images are at the following links: <a href="http://i.stack.imgur.com/XZdhs.png" rel="nofollow">ElementA Model</a>, <a href="http://i.stack.imgur.com/fLVZg.png" rel="nofollow">ElementB Model</a>.</p> <p>As far as troubleshooting goes, I've tried all of the following:</p> <ol> <li>With and without implementing custom classes.</li> <li>Setting ElementA as abstract (however I need it to not be abstract)</li> <li>Removing and then adding in the attributes one at a time (including emptying all attributes of both entities)</li> <li>Resetting Xcode (clean), the simulator (reset all), and restarting my machine.</li> </ol> <p>I've read up on Apple's Docs (Core Data Programming Guide: Managed Object Models) and everything seems to align with their guidelines for Entity Inheritance.</p> <p>This is the line that fails:</p> <pre><code>__persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]]; </code></pre> <p>What do I seem to be missing here? It's got to be obvious as this does not seem like it should be this hard. Any and all help is appreciated!</p> <p><strong>Edit for @Rog's Comment</strong></p> <p>The application fails as soon as the core data model is accessed for the first time at startup. The new images above show that I am trying to set the Parent Entity of ElementB using the Model Editor. The following is the error message I'm receiving:</p> <pre><code>uncaught exception 'NSInternalInconsistencyException', reason: 'Bad model. For entity 'ElementA' subentity 'ElementB (0x785d790)' is not registered in NSManagedModelModel. Model has a reference to ElementB (0x785e320)' </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload