CoreData could not fulfill a fault when adding new attribute

Posted by cagreen on Stack Overflow See other posts from Stack Overflow or by cagreen
Published on 2010-03-11T21:12:55Z Indexed on 2010/03/11 21:14 UTC
Read the original article Hit count: 249

Filed under:
|

I am receiving a "CoreData could not fulfill a fault for ..." error message when trying to access a new attribute in a new data model. If I work with new data I'm ok, but when I attempt to read existing data I get the error. Do I need to handle the entity differently myself if the attribute isn't in my original data? I was under the impression that Core Data could handle this for me. My new attribute is marked as optional with a default value.

I have created a new .xcdatamodel (and set it to be the current version) and updated my NSPersistentStoreCoordinator initialization to take advantage of the lightweight migration as follows:

NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:      
         [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
         [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];

NSError *error = nil;
persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] 
          initWithManagedObjectModel:[self managedObjectModel]];

if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType 
            configuration:nil URL:storeUrl options:options error:&error]) 
{
    NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
    abort();
 }    

Any help is appreciated.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about core-data