核心数据迁移错误消息“'模型不包含配置'XYZ'。'” [英] Core Data Migration error message "'Model does not contain configuration 'XYZ'.'"

查看:128
本文介绍了核心数据迁移错误消息“'模型不包含配置'XYZ'。'”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个托管对象上下文,我添加了两个不同的SQLite存储。我使用Mananged对象模型中的配置来将某些实体分配给一个存储,而将其他实体分配给另一个。配置称为UserDB和MainDB。

I have a Managed Object Context to which I add two different SQLite stores. I use Configurations in the Mananged Object Model to assign certain entities to one store and other entities to the other. The Configurations are called "UserDB" and "MainDB".

一切正常,直到我尝试使用自动迁移。在创建一个新的托管对象模型版本,并添加一个新的属性到UserDB配置中的一个实体后,当将旧版本存储(对于UserDB相关的存储)添加到存储协调器时,会出现异常:'Model does not包含配置'UserDB'。'我在Google上找不到此错误的匹配。任何人在那里使用多个商店与配置?任何人都知道我可能做错了什么?

Everything works okay until I try to use automatic migration. After creating a new Managed Object Model version, and adding a new attribute to one of the entities in the UserDB Configuration, I get an exception when adding the old version store (for the UserDB related store) to the store coordinator: 'Model does not contain configuration 'UserDB'.' I can find no hits for this error on Google. Anyone out there using multiple stores with Configurations? Anyone have an idea what I might be doing wrong?

堆栈看起来像这样:

objc_exception_throw
-[NSManagedObjectModel isConfiguration:compatibleWithStoreMetadata:]
-[NSStoreMigrationPolicy sourceModelForStoreAtURL:metadata:error:]
-[NSStoreMigrationPolicy(InternalMethods) _gatherDataAndPerformMigration:]
-[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:]
-[MyAppDelegate persistentStoreCoordinator] 


推荐答案

这看起来像一个与迁移+配置的错误。我能够解决这个问题,通过相同的动作和传递nil配置调用addPersistentStoreWithType。发生迁移,然后我可以创建一个新的持久化存储协调器,并使用正确的配置字符串参数重新添加存储。

This looks like a bug with migration+configurations. I was able to work around the problem by going through the same motions and passing nil for configuration when calling addPersistentStoreWithType. The migration happens, and then I can make a new persistent store coordinator and add the stores again with the proper Configuration string arguments.

这是第二个配置相关的错误, ve进入。没有经过良好测试的功能显然。

This is the second configuration related bug I've run into. Not a well tested feature apparently.

这篇关于核心数据迁移错误消息“'模型不包含配置'XYZ'。'”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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