核心数据迁移 - 表已存在 [英] Core Data Migration - Table Already Exists

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

问题描述

我有一个现有的iPad应用程序,我刚刚添加了核心数据版本。我已经通过文档,并按照详细的步骤。现在选择我的新模型作为当前版本模型,并试图运行它在我的dev设备从xCode我得到以下错误:

I have an existing iPad application to which I've just added core data versioning. I've been through the documentation and followed the steps detailed. Now after choosing my new model as the current versioned model and trying to run it on my dev device from xCode I get the following error:


2012-03-28 07:35:42.137 DocsOnTap [2603:707] CoreData:error:(1)/ var / mobile / Applications / 06EECF01-3598-4513-8A3A-BE4FD49EEBF6 / Documents /的数据库的I / O错误。 DocsOnTap.sqlite.migrationdestination_41b5a6b5c6e848c462a8480cd24caef3。 SQLite错误代码:1,'表Z_2TAG已经存在'

2012-03-28 07:35:42.137 DocsOnTap[2603:707] CoreData: error: (1) I/O error for database at /var/mobile/Applications/06EECF01-3598-4513-8A3A-BE4FD49EEBF6/Documents/.DocsOnTap.sqlite.migrationdestination_41b5a6b5c6e848c462a8480cd24caef3. SQLite error code:1, 'table Z_2TAG already exists'

我对模型的唯一改变是添加一个新实体。我在我的模型中有一个名为Tag的表 - 这似乎是错误所指的。

The only change that I made to my model was to add in a single new entity. I have a table named Tag in my model - that appears to be what the error is referring to.

如果我将我当前的版本模型还原到以前的版本,那么我可以在我的dev设备上运行我的应用程序从Xcode没有错误。

If I revert my current versioned model back to the previous model version then I can run my app on my dev device from Xcode without error.

我读过,尝试在开发设备上使用核心数据迁移时可能会出现问题。但是我只是想测试一下这个过程,以确保当我们在Appstore中更新我们的应用程序时,迁移工作正如我们的客户所期望的那样。

I have read that there can be problems trying to use core data migration on dev devices. However I just want to test the process to be sure that when we update our app in the Appstore the migration works as expected for our customers.

推荐答案

这是一个模糊的错误。我正在添加的实体被命名为AppKeys - 这必须是核心数据或SQL Lite内部使用的实体的名称。我回到头来,发现我可以添加和迁移其他属性和实体没有任何问题。但是,如果我再次尝试添加我的实体名为AppKeys,然后我得到了相同的错误,说表Z_2TAG已经存在。所以解决我的问题是选择另一个实体名称。很遗憾,这不是记录在明显的地方 - 或者错误不是更有帮助。无论如何,希望这可能只是帮助别人有一天。

Well this was an obscure error. The entity that I was adding was named AppKeys - this must be the name of an entity used internally by core data or SQL Lite. I went back to scratch and found that I could add and migrate other attributes and entities without any problems. However if I tried once again to add my entity named AppKeys then I got the same error saying that 'table Z_2TAG already exists'. So the resolution to my problem is to choose another entity name. It is a pity that this is not documented somewhere obvious - or that the error was not more helpful. Anyway hopefully this might just help someone else one day.

这篇关于核心数据迁移 - 表已存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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