迁移 CoreData 中的实体父级
我有一个已经在 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以创建一个与旧实体具有相同属性的新实体,设置新实体的父实体,然后将旧实体迁移到新实体;
其次,将所有调用更改为新实体。
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.