跨多个版本升级的核心数据迁移 [英] Core Data Migration Across Multiple Version Upgrades

查看:158
本文介绍了跨多个版本升级的核心数据迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Core Data的iPhone应用程序。



我做了一个更新,并使用轻量级迁移从我的MOM(管理对象模型) 。



当我想要使用我的MOM的V3(以及更高版本)时会发生什么?




  • 如果我决定继续轻量级迁移,它会自动处理从我的MOM的V1到V3和V2到V3的迁移,还是需要做额外的工作?

  • 如果我决定使用映射模型,会发生什么?如何处理将V1和V2 MOM升级到V3?我需要为V1到V3和V2到V3创建一个映射模型吗?

  • 这个问题进一步...当我有V6 MOM时仍然需要支持的可能性从V1 MOM升级?



另一个问题是什么是确定当前MOM版本的最佳方法?应该使用isConfiguration:compatibleWithStoreMetadata:



感谢您的帮助。我爱核心数据。但是它有时会让我的头旋转,我很困惑,这就是为什么我寻求一些圣人的智慧。

解决方案

现在很多个月前,但我认为最好的答案是发现在Marcus Zarra的核心数据书(或在线的代码示例)。 Google forprogressiveivelyMigrateURL,并且将找到用于逐步迭代模型的代码 - 这将允许创建从模型n到模型n + 1的映射,而不必担心在所有模型配对之间创建映射的组合爆炸。 p>

这可能导致运行时迁移速度较慢。我没有调查这个。


I have an iPhone app that uses Core Data.

I did an update and used Lightweight Migration to go from V1 to V2 of my MOM (Managed Object Model). This worked perfectly.

What happens when I want to go to V3 (and beyond) of my MOM?

  • If I decide to continue with Lightweight Migration, will it automatically deal with migrating from V1 to V3 and V2 to V3 of my MOM, or do I need to do something extra?
  • If I decide to use a mapping model, what happens? How do I deal with upgrading both V1 and V2 MOM's to V3? Do I need to create a mapping model for both V1 to V3 and V2 to V3?
  • This question goes further ... what happens when I have V6 MOM and still need to support the possibility of upgrading from a V1 MOM?

Another question is what is the best way to determine the version of the current MOM? Should I use isConfiguration:compatibleWithStoreMetadata:

Thanks for any assistance. I am loving Core Data. But it sometimes makes my head spin and I get confused, which is why I am seeking some sage wisdom.

解决方案

The initial posting was now many months ago, but I think that the best answer is found in Marcus Zarra's Core Data book (or online in the code examples). Google for "progressivelyMigrateURL" and one will find code for progressively iterating through models - which would allow one to create mappings from model n to model n+1, while not worrying about the combinatorial explosion for creating mappings between all pairings of models.

This may result in a slower migration at run time. I haven't investigated this.

这篇关于跨多个版本升级的核心数据迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆