Core Data轻量级迁移:无法找到或自动推断迁移的映射模型
因此,我创建了数据模型的新版本,并将以前的可选字段设为非可选(为其指定默认值)。根据文档,这应该意味着我的迁移符合轻量级自动迁移的条件。
我还添加了在打开商店时允许执行此操作的选项,同样根据文档:
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
但是,当我的应用程序启动时,我收到以下错误:
“无法找到或自动推断用于迁移的映射模型”。
有谁知道这里的问题可能是什么?如有任何帮助,我们将不胜感激...谢谢!
So I created a new version of my data model, and made a previously optional field non-optional (giving it a default value). According to the documentation, this should mean my migration is eligible for lightweight, automatic migration.
I also added options that allow this when I open the store, also per the documentation:
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
When my app is starting, however, I get the following error:
"Can't find or automatically infer mapping model for migration".
Does anyone know what the problem here could be? Any help is appreciated... thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能已经看过这个,但如果没有... 检测轻量级核心数据迁移
就其他调试代码而言,我发现这很有帮助:
最后,这有点痛苦,但在 Finder 中,您可以为您的应用程序“显示包内容”,然后找到一个名为 .momd 的文件夹并在其中是一个名为“VersionInfo.plist”的文件。这有助于确定您拥有什么以及您想要去哪里。
最后,您可以尝试创建一个映射模型,看看是否有效。我已经与迁移问题搏斗了好几个星期,因此有一长串绝望的调试尝试。
You've probably looked at this, but if not ... Detecting a Lightweight Core Data Migration
In terms of other debugging code, I found this helpful:
And finally, this is kind of a pain but in the Finder you can "Show Package Contents" for your app and then find a folder called .momd and within that is a file called 'VersionInfo.plist'. This has been helpful in identifying what you have and where you're trying to go.
And finally, you could try to create a mapping model and see if that works. I've wrestled with migration issues for weeks, hence the long list of desperate debugging attempts.