Core Data migration problem: “Persistent store migration failed, missing source managed object model.”

后端 未结 5 1231
耶瑟儿~
耶瑟儿~ 2020-12-16 19:36

The Background

  • A Cocoa Non Document Core Data project with two Managed Object Models.
  • Model 1 stays the same. Model 2 has changed, s
5条回答
  •  甜味超标
    2020-12-16 20:20

    Two possibilities:

    1. Your source model in your app does not match the actual store on disk.
    2. Your mapping model does not match your source model.

    Turn on Core Data debugging and you should be able to see the hashes that Core Data is looking for when it is doing the migration. Compare these hashes to what is in your store on disk and see if they match up. Likewise the debugging should let you see the hashes in the mapping model to help you match everything up.

    If it is just your mapping model that is misaligned, you can tell it to update from source from the design menu in Xcode. If you are missing the actual source model for your store file on disk then you can look in your version control system or try using an automatic migration to get that file to migrate to the model that you believe is the source.

    Update 1

    The location for changing the source and destination models has moved to the bottom of the editor window:

提交回复
热议问题