iosswiftcore-datamagicalrecordcore-data-migration

CoreData removes all objects after updating Model.xcdatamodeld


I am using MagicalRecord and Swift.

Here is my case:

Why? Any ways do handle that?


Solution

  • If you are updating the xcdatamodeld file after running on your device and then running again, the chances are there is a conflict in xcdatamodeld files. You need to add a new version everytime you make changes to your data model. The current active xcdatamodel file is stored having omo extension. If this was the case the app would've crashed immediately and I see you updating your model maybe its something to do with MagicalRecord.