Core Data轻量级迁移:找不到或自动推断用于迁移的映射模型 [英] Core Data lightweight migration: Can't find or automatically infer mapping model for migration

查看:320
本文介绍了Core Data轻量级迁移:找不到或自动推断用于迁移的映射模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我创建了一个新版本的我的数据模型,并使一个以前的可选字段不可选(给它一个默认值)。根据文档,这意味着我的迁移有资格进行轻量级的自动迁移。

So I created a new version of my data model, and made a previously optional field non-optional (giving it a default value). According to the documentation, this should mean my migration is eligible for lightweight, automatic migration.

我还添加了一些选项,当我打开商店,也根据文档:

I also added options that allow this when I open the store, also per the documentation:

NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:

                    [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,

                    [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];

但是,当我的应用程序启动时,会出现以下错误:找不到或自动推断用于迁移的映射模型。

When my app is starting, however, I get the following error: "Can't find or automatically infer mapping model for migration".

有没有人知道这里的问题是什么?任何帮助是感谢...谢谢!

Does anyone know what the problem here could be? Any help is appreciated... thanks!

推荐答案

你可能看过这个,但如果不是... 检测轻量级核心数据迁移

You've probably looked at this, but if not ... Detecting a Lightweight Core Data Migration

在其他调试代码方面,我发现这是有帮助的:

In terms of other debugging code, I found this helpful:

   NSURL *storeUrl = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"MyDataStore.sqlite"]];

NSError *error = nil;
NSDictionary *sourceMetadata = [NSPersistentStoreCoordinator metadataForPersistentStoreOfType:NSSQLiteStoreType
                                                                URL:storeUrl
                                                                error:&error];

if (!sourceMetadata)
    {
    DLog(@"sourceMetadata is nil");
    }
else
    {
    DLog(@"sourceMetadata is %@", sourceMetadata);
    }

最后,这是一种痛苦,但在Finder中,显示包内容,然后找到一个名为.momd的文件夹,其中包含一个名为VersionInfo.plist的文件。这有助于识别你有什么,以及你想去哪里。

And finally, this is kind of a pain but in the Finder you can "Show Package Contents" for your app and then find a folder called .momd and within that is a file called 'VersionInfo.plist'. This has been helpful in identifying what you have and where you're trying to go.

最后,你可以尝试创建一个映射模型,看看是否可行。我已经挣扎了几个星期的迁移问题,因此一系列绝望的调试尝试。

And finally, you could try to create a mapping model and see if that works. I've wrestled with migration issues for weeks, hence the long list of desperate debugging attempts.

这篇关于Core Data轻量级迁移:找不到或自动推断用于迁移的映射模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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