修改核心数据模型需要每次新版本? [英] Modifying the Core Data Model Requires New Version Every Time?

查看:124
本文介绍了修改核心数据模型需要每次新版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找,让我直接,每次我改变我的实体的属性,我需要创建一个全新的版本的模型?我知道SQLite数据库现在与我的数据模型不同步,但我不能只删除sql文件,并重新运行我的模拟器?这是我一直在做,但它似乎不工作。

I've been searching around and let me get this straight, every time I change the attributes of my entities, I need to create an entirely new version of my model? I understand that the SQLite database is now out of sync with my data model, but can't I just delete the sql files and re-run my simulator? This is what I've been doing, but it doesn't seem to be working.

推荐答案

到核心数据模型必须在新的核心数据模型版本中。您可以通过重置模拟器中的内容和设置,或在安装之前删除设备上的旧应用程序版本,避免为开发构建执行此操作。但是对于商店构建,您必须正确地管理模型版本,以便用户将其持久存储正确迁移到具有新模型的新商店。需要进行版本控制,以便可以执行轻量级迁移,而无需编写自定义迁移代码。如果不想对模型进行版本化,则必须编写代码以正确迁移实体。这可能是很多工作,很难维护,你宁愿使用轻量级迁移和版本控制。

You are correct, any changes to the core data model must be made in a new core data model version. You can avoid having to do this for development builds by resetting content and settings in the simulator, or deleting the old app version on a device before installing. For store builds though, you must correctly manage your model versions so that user's will have their persistent store properly migrated to a new store with the new model. Versioning is required so that lightweight migrations can be performed, without you having to write custom migration code. If you don't want to version your model, you are bound to writing code to properly migrate your entities. This can be a lot of work and difficult to maintain, you'd rather use lightweight migration and versioning.

这篇关于修改核心数据模型需要每次新版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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