将CoreData迁移到新版本时出现以下错误。我正在使用CoreData的自动迁移。我的CoreData存储文档,当数据大小很大时,它就会开始发生。是否Core Data无法使用自动迁移迁移大数据。崩溃后,当我检查文件目录时,它显示以下文件:
错误:
数据库在 /var/mobile/Containers/Data/Application/782EE7A8-729F-429C-84AF-501B5F866592/Documents/DocViewer.sqlite 已经腐败了。 SQLite错误代码:11,'数据库磁盘映像是 畸形“
这是我对persistentStore的实现:
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
if (_persistentStoreCoordinator != nil)
{
return _persistentStoreCoordinator;
}
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"DocViewer.sqlite"];
//738001
NSDictionary *options = @{
NSMigratePersistentStoresAutomaticallyOption : @YES,
NSInferMappingModelAutomaticallyOption : @YES,
NSSQLitePragmasOption:@{@"journal_mode":@"DELETE"}
};
NSError *error = nil;
_persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error])
{
ADLog(@"Unresolved error %@, %@", error, [error userInfo]);
//abort();
}
storeURL = nil;
options = nil;
return _persistentStoreCoordinator;
}