Question

I have an existing project we'll call ABC. I have a new project we'll call XYZ.

All I'm trying to do is copy the MyDataModel.xcdatamodeld from the ABC project folder into the XYZ project folder, and copy the associated populated MyDatabase.sqlite file from the simulator on project ABC into the simulator on project XYZ.

This does NOT work.

I get the error "The model used to open the store is incompatible with the one used to create the store"

I've tried resetting simulator, deleting all apps from simulator, running CLEAN in XCode, and still doesn't work.

When I run XYZ, it WILL create a new EMPTY sqlite database, but it will NOT accept my populated one that is associated with the ABC project and which works fine in ABC.

I need to be able to use my populated one.

Was it helpful?

Solution

The error message tells the tale. You have changed the xcdatamodeld between the time you wrote MyDatabase.sqlite and now. Core Data needs the original xcdatamodeld (unchanged) to be able to read your datafile. Retrieve it from your version control system or from Time Machine and you'll be good to go, although you might have to handle model migration.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top