I am attempting to add a new entity (say B, with two "double" attributes) to my core data model and create an optional to-many relationship with an existing entity (say A). I created the new model revision that includes the new entity B, the existing entity A, and a to-many relationship A ->> B. This new model is the default model. I created a mapping model from v2 to v3 (v1 -> v2 migration works fine, just data type changes for entity A), but did not specify a value expression for A's relationship to B, nor value expressions for B's attributes.
When I run the app, I receive the following error when attempting to instantiate the managed object model managedObjectModel = [[NSManagedObjectModel mergedModelFromBundles:nil] retain];
.
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSMutableArray insertObject:atIndex:]: attempt to insert nil object at 0'.
The problem is probably that I did not specify a value expression for A's relationship to B in the mapping model, but I thought that its not necessary because B is optional and it did not exist in v2 of the model. If I do have to specify a value expression for relationship, how do I do so for a non-existent (as it doesn't exist in v2 of the model) optional relationship?
Any help is greatly appreciated.
PS - one more question - is a mapping model even necessary, or is automatic migration smart enought to to handle the new entity and the relationship?