Incorrect configuration name on first launch from NSPersistentContainer

I'm wondering if this is an issue with the NSPersistentContainer or something else is going on but when I launch the new model for my app and try to save a new relationship to an object it fails.


Unresolved error Error Domain=NSCocoaErrorDomain Code=134020 The model configuration used to open the store is incompatible with the one that was used to create the store.


NSUnderlyingException=Can't resolve how to assign objects to stores; some objects may have been assigned to stores; use [[managedObject objectID] persistentStore] to find out what is going where now


This only happens on the first launch and I can see why. The configuration name is reported as "PF_DEFAULT_CONFIGURATION_NAME" rather than "Users" as it should be. Once the app is relaunched all works fine and the configuration reports correctly from launch.

You probably changed your .xcdatamodeld file without first creating a new version. Click on the file in your project and then go to Editor / Add Model Version... That will add a new version of your data model. Add your changes in there. Make sure that the new version is the default version. If you are just testing your app before you upload to the app store, then don't worry about creating another data model. Keep on changing your existing model until you are satisfied with it. Try to use lightweight migration if at all possible.

Incorrect configuration name on first launch from NSPersistentContainer
 
 
Q