Can't find mapping model for migration - UIManagedDocument Core Data Migration

后端 未结 5 1042
说谎
说谎 2021-02-08 18:50

I have two versions of my model Model001.xcdatamodel and Model002.xcdatamodel. These two are in the Model.xcdatamodeld bundle. I also have

5条回答
  •  攒了一身酷
    2021-02-08 19:26

    You are not allowed to make any changes to the source/destination model after you have created the mapping models.

    If you do make some changes,

    • mappingModelFromBundles:forSourceModel:destinationModel: will not be able to find the mapping model file
    • addPersistentStoreWithType:configuration:URL:options:error: with {NSInferMappingModelAutomaticallyOption: @NO} will report an error "Can't find mapping model for migration"
    • migrateStoreFromURL:type:options:withMappingModel:toDestinationURL:destinationType:destinationOptions:error: will report an error "Mismatch between mapping and source/destination models"

    So, just recreate the mapping model and copy every change you made in the old one.

提交回复
热议问题