CoreData - 数据模型
创建一个实体并成功运行该应用程序后,我意识到我错过了其中的一些内容。我添加了新属性,现在收到有关不同数据模型的错误,无法打开,SIGABRT(换句话说,但我认为您明白了)。我该如何重置数据模型,或者我是否必须创建一个新实体?如果后者是真的,那么它似乎非常不灵活,因为我已经删除了从应用程序内保存的所有数据。
Having created an entity, and run the app successfully, I realised I had missed something out of it. I added the new attribute and now get an error regarding different data models, unable to open, SIGABRT (to paraphrase, but I think you get the picture). How do I go about resetting the data model, or will I have to create a new entity? If the latter is true, it seems very inflexible as I have deleted all of the data I saved from within the app.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要迁移数据模型。请参阅核心数据编程指南中的迁移。
基本问题是您当前的商店是针对旧模型进行格式化的。它根本没有地方容纳新属性。要保留当前数据,您需要执行迁移。如果您仍处于开发阶段并且不关心数据,则可以删除 SQL 存储并从新模型开始。
You need to migrate the data model. See Migration in the Core Data Programming Guide.
The basic problem is that your current store is formatted for the old model. It simply has no place for the new attribute. To keep the current data, you need to perform a migration. If you are just still in development and don't care about the data, you can just delete the SQL store and start over with the new model.