Search code examples
core-datadatamodel

CoreData - Data Models


Having created an entity, and run the app successfully, I realised I had missed something out of it. I added the new attribute and now get an error regarding different data models, unable to open, SIGABRT (to paraphrase, but I think you get the picture). How do I go about resetting the data model, or will I have to create a new entity? If the latter is true, it seems very inflexible as I have deleted all of the data I saved from within the app.


Solution

  • You need to migrate the data model. See Migration in the Core Data Programming Guide.

    The basic problem is that your current store is formatted for the old model. It simply has no place for the new attribute. To keep the current data, you need to perform a migration. If you are just still in development and don't care about the data, you can just delete the SQL store and start over with the new model.