Search code examples
iphoneiosios4core-data

Core Data - Application crashes after adding extra attributes to xcddatamodel file


I am using core data in my application. For data I link the sqlite file with it. All of my data is fetched successfully and I get the proper results. When I add some more attributes to the core data entity and then run the application then it crashes.

My error message: "The model used to open the store is incompatible with the one used to create the store"

So may be it seem because i have changed the Data model. Now what should i have to do if i want to add some extra fields in to my coredata model without the application crashing?


Solution

  • The reason it crashes is because your app's data model is inconsistent. In fact you should be getting an error message very similar to that.

    What you can do to fix it is the delete your app off of the simulator or phone, and then simply rebuild and rerun from xcode.

    Additionally, to avoid this problem in the future, you can configure core data to look for, and accept extensions of your data model, though I have not implemented this so I couldn't tell you how to do it exactly. Some searching online should yield a correct example.