Core Data lightweight migration fails when merging models from main bundle

Number:rdar://13077068 Date Originated:24-Jan-2013 11:05 AM
Status:Open Resolved:
Product:iPhone SDK Product Version:6.0
Classification:Crash Reproducible:Always
When using more than one model file (and one entity is updated to a new version) and merging them at runtime the lightweight migration fails with the error "Can't find model for source store" (Cocoa error 134130).

Steps to Reproduce:
See attached git project.

1) git submodule update --init --recursive (Make sure that MagicalRecord is in project)
2) git checkout 04de690
- Launch the app. 
- Press the buttons 'Create Person' and 'Create Animal'. This will create a new entity Person and Animal. The objectID of the animal is saved to the person object.

3) git checkout a8537b4 (A new version of Person entity is created and property lastname is added.)
- Launch the app.
- Debug NSPersistentStoreCoordinator+MagicalRecord.m:78 and inspect the error variable.
- Press the buttons 'Create Person' and 'Create Animal'. When trying to save the animal object, the app crashes because no persistent store could be created.

Expected Results:
The migration should work even though the model for the sqlite database file is merged at runtime.

Actual Results:
The migration fails because the source model couldn't be found. It seems like the merged model doesn't include the old version of the model. Therefore the sqlite database can't be opened.

No regression testing was done.

When putting both entities in one model file, the migration works without changing the Core Data setup code. You can verify this by 
1) git checkout 6bd89fc
- Do same steps as above
2) git checkout 68c79de
- Do same steps as above and you will see that the migration works and the Person has the new property 'lastname'.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!