本文介绍了Core数据迁移失败NSPersistenceFrameworkVersions 251和358之间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的数据存储(NSSQLiteStoreType)没有被正确地自动迁移。 / p>

注意,应用程序的iOS版本使用完全相同的Core Data模型。





直到最新版本都能正常工作。



>我有14个版本的模型 - 模型13已经运行了一段时间没有事件。



最近我更新了我的应用程序,并添加了一个新的模型,所以我at 14(这是发货应用程序中现在使用的版本)。



iOS版本在从模型13迁移到14时工作正常 - 因此无需担心关于这一点。



所以,而不是谈论OS X版本允许使用NSPersistenceFrameworkVersions



NSPersistenceFrameworkVersions 251是10.6.8和NSPersistenceFrameworkVersions 358是10.7.1



如果我们使用类似的版本 - 意味着模型13版本251和迁移到模型14版本251它工作正常。



同样是真的,如果我们使用模型13版本358和迁移到模型14版本358它也可以正常工作



有趣



如果我们将模型13版本358迁移到模型14版本251,它仍然可以正常工作



从模型13版本251到模型14版本358执行工作



CoreData:错误:(1)数据库的I / O错误。 SQLite错误代码:1,'没有这样的列:FOK_REFLEXIVE'



同样,只有当从10.6.8(NSPersistenceFrameworkVersions 251)到10.7.1(NSPersistenceFrameworkVersions 358)



下面是用于迁移的选项传递给addPersistentStoreWithType。

  //允许从应用程序的原始版本推断迁移。 
NSDictionary * options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES],NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES],NSInferMappingModelAutomaticallyOption,nil];最后一点,如果我们只向模型14添加属性,转换将会不是休息。只有添加一个实体才会导致它破裂。



任何人都看到这种问题。

解决方案

此问题似乎已在iOS 5.1和OSX 10.7.3中修复


I have what appears to be a bug with Core Data in OS X 10.7.1.

My data store (NSSQLiteStoreType) is not being automatically migrated correctly.

As a side note the exact same Core Data models are used by an iOS version of the app.

-> Here is what appears to be happening.

Up until the latest release everything has been working fine --

I have 14 revisions of the model -- model 13 has been shipping for quite some time without incident.

Recently I updated my app and added a new model so I am at 14 (this is the version now used in the shipping apps).

The iOS version works just fine when migrating from model 13 to 14 -- so no need to worry about that.

So rather then talking about OS X versions lets use NSPersistenceFrameworkVersions

NSPersistenceFrameworkVersions 251 being 10.6.8 and NSPersistenceFrameworkVersions 358 being 10.7.1

If we use like versions -- meaning model 13 version 251 and migrate to model 14 version 251 it works fine.

same is true if we use model 13 version 358 and migrate to model 14 version 358 it also works fine

Here is where it gets interesting

if we migrate model 13 version 358 to model 14 version 251 it still works fine

However migrating from model 13 version 251 to model 14 version 358 does not work

CoreData: error: (1) I/O error for database at blah. SQLite error code:1, 'no such column: FOK_REFLEXIVE'

Again this only happens when going from 10.6.8 (NSPersistenceFrameworkVersions 251) to 10.7.1 (NSPersistenceFrameworkVersions 358) all other permutations work just fine.

Here are the options used for migration that get passed to addPersistentStoreWithType.

// Allow inferred migration from the original version of the application.
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
                         [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
                         [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];

One final thing, it appears if we only add attributes to model 14 the conversion will not break. It is only with the addition of an entity that will cause it to break.

Anybody else seeing this sort of problem. -thanks in advance.

解决方案

This bug appears to have been fixed in iOS 5.1 and OSX 10.7.3

这篇关于Core数据迁移失败NSPersistenceFrameworkVersions 251和358之间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 17:33