迁移 CoreData 中的实体父级

发布于 2024-12-15 05:15:32 字数 285 浏览 4 评论 0原文

我有一个已经在 App Store 中使用的 CoreDatabase 模型,因此我需要设计一种方法来迁移模型而不丢失以前的数据。我有一个实体当前没有父对象,但我需要在新模型中设置其父实体。但是,当我尝试执行此操作时,出现崩溃,提示 CoreData 无法迁移数据库模型。

如果有人能够提供有关我如何实现这一目标的见解,我将非常感激!

编辑:我收到无法迁移存储就地错误,其基本错误为“SQLite 错误代码:1,'没有这样的表:_T_ZCONTACT',原因=无法执行迁移语句”。 “联系人”是我需要更改其父级的实体的名称。

I have a CoreDatabase model that is already used in the App Store, so I need to devise a way to migrate the model without losing the previous data. I have an entity that currently does not have a parent object, but I need to set its parent entity in the new model. However, when I try to do this, I get a crash that says that CoreData was unable to migrate the database model.

If anyone could provide an insight into how I would accomplish this, I'd really appreciate it!

EDIT: I get an Cannot migrate store in-place error with the underlying error of "SQLite error code:1, 'no such table: _T_ZCONTACT', reason=Failed to execute migration statements". The "Contact" is the name of the entity I need to change the parent for.

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

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

发布评论

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

评论(1

已下线请稍等 2024-12-22 05:15:32

您可以创建一个与旧实体具有相同属性的新实体,设置新实体的父实体,然后将旧实体迁移到新实体;
其次,将所有调用更改为新实体。

You may create a new entity having the same attributes as the old entity, set the new one's parent, then migrate the old entity to new one;
second, change all of invoke to the new entity.

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