核心数据迁移 - “无法添加源存储”错误

发布于 2024-08-23 03:29:42 字数 1058 浏览 3 评论 0原文

在我的 iPhone 应用程序中,我使用的是 Core Data,并且我对无法自动迁移的数据模型进行了更改(即添加了新关系)。我添加了数据模型版本(设计 -> 数据模型 -> 添加模型版本),并将新的数据模型更改应用到新版本 2。然后,我创建了一个映射对象模型,并将源模型和目标模型设置为正确的值数据模型(分别是旧的和新的)。

当我运行应用程序并调用 persistenceStoreCoordinator 时,我的应用程序出现以下错误:

2010-02-27 02:40:30.922 XXXX[73578:20b] 未解决的错误 Error Domain=NSCocoaErrorDomain Code=134110 UserInfo=0xfc2240 "Operation无法完成。(可可错误 134110。)", { NSUnderlyingError = 错误域=NSCocoaErrorDomain Code=134130 UserInfo=0xfbb3a0“操作无法完成。(Cocoa 错误 134130。)”; Reason = "无法添加源商店"; FWIW

(我认为不多)我还在 persistenceStoreCoordinator 中进行了常规代码更改,以使用 NSMigratePersistentStoresAutomaticallyOption 和 NSInferMappingModelAutomaticallyOption (用于将来可以自动迁移的数据模型更改)。更相关的是,我的 ManagedObjectModel 是通过调用 initWithContentsOfURL 创建的,其中文件/资源​​类型为“momd”。

我尝试更新映射模型中的源模型和目标模型(设计 -> 映射模型 -> 更新 XXX 模型),以及删除映射模型并重新创建它。我已经清理并重建过,但都无济于事。我仍然收到上述错误消息。

有关如何进一步调试或解决此问题的任何指示/想法吗?我没有发布任何代码片段,因为这感觉更像是构建环境问题(并且我的代码非常标准 - 只是使用映射模型处理迁移的常用核心数据代码,但我很乐意展示代码,如果它有帮助)。

感谢任何帮助。

谢谢

In my iPhone app I'm using Core Data and I've made changes to my data model that cannot be automatically migrated over (i.e. added new relationships). I added the data model version (Design -> Data Model -> Add Model Version) and applied my new data model changes to the new version 2. I then created a mapping object model and set the Source and Destination models to their correct data models (old and new respectively).

When I run the app and call the persistentStoreCoordinator, my app barfs with the following:

2010-02-27 02:40:30.922 XXXX[73578:20b] Unresolved error Error Domain=NSCocoaErrorDomain Code=134110 UserInfo=0xfc2240 "Operation could not be completed. (Cocoa error 134110.)", {
NSUnderlyingError = Error Domain=NSCocoaErrorDomain Code=134130 UserInfo=0xfbb3a0 "Operation could not be completed. (Cocoa error 134130.)";
reason = "Can't add source store";

}

FWIW (not much i think) I've also made the usual code changes in persistentStoreCoordinator to use the NSMigratePersistentStoresAutomaticallyOption and NSInferMappingModelAutomaticallyOption (for future data model changes that can be automatically migrated). More relevantly, my managedObjectModel is created by calling initWithContentsOfURL where the file/resource type is "momd".

I've tried updating both the source and destination model in the mapping model (Design -> Mapping Model -> Update XXX Model) as well as deleted the mapping model and recreated it. I've cleaned and re-built but all to no avail. I still get the above error message.

Any pointers/thoughts on how I can further debug or resolve this problem please? I haven't posted any code snippets because this feels much more like a build environment issue (and my code is very standard - just the usual core data code to handle migrations using a mapping model but I'm happy to show the code if it helps).

Appreciate any help.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光与爱终年不遇 2024-08-30 03:29:42

好的,现在已经解决了。

我(a)删除并重新创建了我的托管对象模型类,(b)删除并重新创建了映射模型,最后我(c)删除了 users/xxx/Library/Application Support/iPhone Simulator/User 下的 iphone 项目/应用程序。

鉴于我之前尝试仅执行(a)和(b)但失败了,我怀疑是(c)解决了问题。

Ok, this is now fixed.

I (a) deleted and then recreated my managed object model classes, (b) deleted and then recreated the mapping model and then finally I (c) deleted the iphone project under the users/xxx/Library/Application Support/iPhone Simulator/User/Applications.

Given I previously tried and failed with doing just (a) and (b), I suspect it was (c) which fixed the problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文