To not crash like 3.1, create a new model version before modifying the model. Once added, a new Xcdatamodel file is generated and is exactly the same as the original content, which is interesting, but do not delete the old version of the original model. The old model helps to migrate the original persisted store to the current model version.
To modify a program:
- Select Model.xcdatamodeld
- Click Editor > Add Model Version ...
- Click Finish to use Model 2 as the version name by default
Note that we are going to revise the new template and slowly get to the point:
- Note the Backup program
- Select Model 2.xcdatamodel
- As with 3.1, create the entity measurement and create a string-type property on it ABC
- Select Model.xcdatamodeld, and then click menu View > Utilities > Show File Inspector to set current model Version to model 2, or modify as shown above
After configuring this, you also need to set the migration options to tell the core data how it should be migrated, and now run the program, which is sure to have a 3.1 error.
3.2. Add a template version (Core Data Application Practice Guide)