我真的希望有人能够帮助我解决这个问题。
我第一次尝试在 Xcode 中创建数据映射模型(针对 iOs 应用程序)。
这应该是一个非常简单的迁移(尽管不包括在轻量级迁移中);这是我最初拥有的以及新数据库的样子:
更改内容:
- 我有一个新属性 (
DBdisplayOrder
),这是可选的
- 我有一个新的多对多关系。我想将旧数据库的
DBreminder
(NSDate) 属性移至新的 DBreminderDate
。新表中的两个属性都是可选的。
所以基本上我只需要从一个属性复制数据,该属性现在驻留在一个新实体中。
如果有人能给我指出正确的方向,或者只是推荐一个好的资源来学习和入门,我将非常感激。
I really hope someone will be able to help me out with this.
I am trying to create a data mapping model (for an iOs app) in Xcode for the first time.
This should be a very simple migration (although not covered by lightweight migration); here is what I originally had and what the new database looks like:
What changed:
- I have a new attribute (
DBdisplayOrder
), which is optional
- I have a new to-many relationship. I would like to move the old database's
DBreminder
(NSDate) attribute to the new DBreminderDate
. Both attributes in the new table are optional.
So basically I only need to copy data from one attribute, which now resides in a new entity.
I would be very grateful if someone could point me in the right direction, or just recommend a good resource to study from and get started.
发布评论
评论(2)
我已经使用找到的一个很好的描述来出售这个问题 这里。
更新: (固定链接似乎是同一篇博客文章)
这是工作映射模型:
我希望它对某人有所帮助。
I have sold this problem using a great description found here.
Update: (Fixed link to what appears to be the same blog post)
Here is the working mapping model:
I hope it helps someone.
创建映射模型可能会涉及相当多的工作。我将从 核心数据模型版本控制和数据迁移编程指南
在这种特殊情况下,您将需要创建一个显式映射模型,然后您将必须创建一个实体映射来描述您的原始实体和您想要将属性移动到的新目标实体。然后为该特定属性创建属性映射。
Creating a mapping model can get fairly involved. I would start with the Core Data Model Versioning and Data Migration Programming Guide
In this particular case you will need to create an explicit mapping model, then you will have to create an entity mappings that describes both your original entity and the new target entity you want to move the attribute to. Then create a property mapping for that particular attribute.