问题描述
这个问题困扰我很多,并尝试得到一些帮助。我知道这是一个旧的,但我仍然没有找到解决方案。
This problem bothers me a lot and try to get some help.I knew this is a old one but I still don't find the solution.
在我的应用程序,我尝试使用modelByMergingModels收集我的所有数据模型到一个,然后传递到persistentStoreCoordinator。一切都很好,直到我需要实现数据迁移,以防万一数据模型将在未来更改。
In my application, I try to use modelByMergingModels to gather all my data models into one, then pass to the persistentStoreCoordinator. Everything is fine until I need to implement the data migration just in case the data model will be changed in the future.
这里是我做的步骤。
1.设计 - 添加模态版本以创建新数据
2.添加一个新属性SAVE
3.将light数据迁移选项字典添加到addPersistentStoreWithType方法
4。运行程序并获取错误。 无法找到源存储的模型;
Here are the steps I did.1. Design-Add modal version to create a new data2. Add a new attribute,SAVE3. Add the light data migration options dictionary to addPersistentStoreWithType method4. Run the programs and get the error. "Can't find model for source store";
但是,如果我将managedObjectModel访问器更改为init只有一个数据模型,并摆脱modelByMergeingModels或mergedModelFromBundles。它只是工作。
However, if I change my managedObjectModel accessor to init only one data model and get rid of the modelByMergeingModels or mergedModelFromBundles. It just works.
所以我的问题是,当我使用合并模型或mergedModelFromBundles数据迁移工作吗?
So my question is, does data migration works when I use merge models or mergedModelFromBundles?
如果我有多个数据模型并尝试实现数据迁移,最好的方法是什么。
What's the best way if I have multiple data models and try to implement the data migration.
希望这个问题有意义。非常感谢。
Hope the question make sense. Many thanks
推荐答案
这是Core Data中的一个错误。请在上打开雷达,以便苹果了解更多人遇到此问题
This is currently a bug in Core Data. Please open a radar at http://bugreport.apple.com so that Apple will know more people are having this problem.
至于解决方法,我不知道一个,但你可以尝试单独迁移模型。
As for a workaround, I am not aware of one, however you may try migrating the models individually.
这篇关于合并模型可以使用光数据迁移吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!