Core data model configuration & Leopard

  • I have a relatively simple core data non-document application that
    runs fine under OS 10.4.  However, when I run the same app on OS
    10.5, it cannot open the data file.  I get the error "The model
    configuration used to open the store is incompatible with the one
    that was used to create the store."  I traced the first time this was
    called to the code below, the call to addPersistentStoreWithType.
    The method "managedObjectContext" has not changed since I created the
    project with Xcode.  Does anyone have any suggestions as what I can
    do to get my app to read the store in OS 10.5?

    Thanks,
    Kyle

    - (NSManagedObjectContext *) managedObjectContext {
    NSError *error;
    NSString *applicationSupportFolder = nil;
    NSURL *url;
    NSFileManager *fileManager;
    NSPersistentStoreCoordinator *coordinator;

    if (managedObjectContext) {
      return managedObjectContext;
    }

    fileManager = [NSFileManager defaultManager];
    applicationSupportFolder = [self applicationSupportFolder];
    if ( ![fileManager fileExistsAtPath:applicationSupportFolder
    isDirectory:NULL] ) {
      [fileManager createDirectoryAtPath:applicationSupportFolder
    attributes:nil];
    }

    url = [NSURL fileURLWithPath: [applicationSupportFolder
    stringByAppendingPathComponent: @"MyData.sqlite"]];
    coordinator = [[NSPersistentStoreCoordinator alloc]
    initWithManagedObjectModel: [self managedObjectModel]];
    ->    if ([coordinator addPersistentStoreWithType:NSSQLiteStoreType
    configuration:nil URL:url options:nil error:&error]){
      managedObjectContext = [[NSManagedObjectContext alloc] init];
      [managedObjectContext setPersistentStoreCoordinator: coordinator];
    } else {
      [[NSApplication sharedApplication] presentError:error];
    }
    [coordinator release];

    return managedObjectContext;
    }
  • On Oct 28, 2007, at 5:45 PM, <cocoalist...> wrote:

    > I have a relatively simple core data non-document application that
    > runs fine under OS 10.4.  However, when I run the same app on OS
    > 10.5, it cannot open the data file.  I get the error "The model
    > configuration used to open the store is incompatible with the one
    > that was used to create the store."  I traced the first time this
    > was called to the code below, the call to
    > addPersistentStoreWithType.  The method "managedObjectContext" has
    > not changed since I created the project with Xcode.  Does anyone
    > have any suggestions as what I can do to get my app to read the
    > store in OS 10.5?
    >
    Has the *model* changed in any way?  With the new versioning and
    migration feature in 10.5, Core Data takes the following into account:
    Core Data’s perspective on versioning is that it is only interested in
    features of the model that affect persistence. This means that for two
    models to be compatible:

    • For each entity the following attributes must be equal: name,
    parent, isAbstract, and properties.
    className, userInfo, and validation predicates are not compared.

    • For each property in each entity, the following attributes must be
    equal: name, isOptional,isTransient, isReadOnly, for attributes
    attributeType, and for relationshipsdestinationEntity, minCount,
    maxCount, deleteRule, and inverseRelationship.
    userInfo and validation predicates are not compared.

    (see Core Data Model Versioning and Data Migration Programming Guide >
    Versioning).

    Not all this information is maintained in the store, but it *may* be
    that you managed to get away with something on Tiger that isn't now
    allowed on Leopard.

    mmalc
  • On Oct 28, 2007, at 6:12 PM, mmalc crawford wrote:
    >
    > On Oct 28, 2007, at 5:45 PM, <cocoalist...> wrote:
    >
    >> I have a relatively simple core data non-document application that
    >> runs fine under OS 10.4.  However, when I run the same app on OS
    >> 10.5, it cannot open the data file.  I get the error "The model
    >> configuration used to open the store is incompatible with the one
    >> that was used to create the store."  I traced the first time this
    >> was called to the code below, the call to
    >> addPersistentStoreWithType.  The method "managedObjectContext" has
    >> not changed since I created the project with Xcode.  Does anyone
    >> have any suggestions as what I can do to get my app to read the
    >> store in OS 10.5?
    >>
    > Has the *model* changed in any way?  With the new versioning and
    > migration feature in 10.5, Core Data takes the following into account:
    > Core Data’s perspective on versioning is that it is only interested
    > in features of the model that affect persistence. This means that
    > for two models to be compatible:
    >
    > • For each entity the following attributes must be equal: name,
    > parent, isAbstract, and properties.
    > className, userInfo, and validation predicates are not compared.
    >
    > • For each property in each entity, the following attributes must
    > be equal: name, isOptional,isTransient, isReadOnly, for attributes
    > attributeType, and for relationshipsdestinationEntity, minCount,
    > maxCount, deleteRule, and inverseRelationship.
    > userInfo and validation predicates are not compared.
    >
    > (see Core Data Model Versioning and Data Migration Programming
    > Guide > Versioning).
    >
    > Not all this information is maintained in the store, but it *may*
    > be that you managed to get away with something on Tiger that isn't
    > now allowed on Leopard.
    >
    > mmalc
    >

    There has only been one model, and that model has not changed since I
    created the product a few years ago.  The product uses two entities.
    One is never used.  Could that be an issue?  If not, anything else I
    should look at?
    Thanks,
    Bill
  • On Oct 28, 2007, at 6:18 PM, Bill wrote:

    > There has only been one model, and that model has not changed since
    > I created the product a few years ago.  The product uses two
    > entities.  One is never used.  Could that be an issue?  If not,
    > anything else I should look at?
    >
    Hmm, try:

    NSDictionary *optionsDictionary =
    [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES]
      forKey:NSIgnorePersistentStoreVersioningOption];
    if ([coordinator addPersistentStoreWithType:NSSQLiteStoreType
    configuration:nil
    URL:url options:optionsDictionary error:&error]){

    mmalc
  • On Oct 28, 2007, at 6:26 PM, mmalc crawford wrote:

    >
    > On Oct 28, 2007, at 6:18 PM, Bill wrote:
    >
    >> There has only been one model, and that model has not changed
    >> since I created the product a few years ago.  The product uses two
    >> entities.  One is never used.  Could that be an issue?  If not,
    >> anything else I should look at?
    >>
    > Hmm, try:
    >
    > NSDictionary *optionsDictionary =
    > [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES]
    > forKey:NSIgnorePersistentStoreVersioningOption];
    > if ([coordinator addPersistentStoreWithType:NSSQLiteStoreType
    > configuration:nil
    > URL:url options:optionsDictionary error:&error]){
    >
    > mmalc
    >

    No, that didn't work.  However, I created a new xcode project which
    read the same store, and it opened the store without any issues, so I
    guess I'm doing something wrong somewhere in my original project.  If
    you have any hints as to where to look, I'd appreciate it, but I
    guess I'm just going to have to some serious debugging.

    Thanks,
    Bill
  • I've seen no info about the "isIndexed" attributes migration.
    I have model working on Tiger with no index placed on any attributes,
    but now, I would like to index some attributes. How does it affect
    models compatibility?
    Is it managed by the migration manager ? is it safe to simply check
    this checkbox in Xcode modeler?

    Thanks.

    On 29 oct. 07, at 02:12, mmalc crawford wrote:

    >
    > On Oct 28, 2007, at 5:45 PM, <cocoalist...> wrote:
    >
    >> I have a relatively simple core data non-document application that
    >> runs fine under OS 10.4.  However, when I run the same app on OS
    >> 10.5, it cannot open the data file.  I get the error "The model
    >> configuration used to open the store is incompatible with the one
    >> that was used to create the store."  I traced the first time this
    >> was called to the code below, the call to
    >> addPersistentStoreWithType.  The method "managedObjectContext" has
    >> not changed since I created the project with Xcode.  Does anyone
    >> have any suggestions as what I can do to get my app to read the
    >> store in OS 10.5?
    >>
    > Has the *model* changed in any way?  With the new versioning and
    > migration feature in 10.5, Core Data takes the following into account:
    > Core Data’s perspective on versioning is that it is only interested
    > in features of the model that affect persistence. This means that
    > for two models to be compatible:
    >
    > • For each entity the following attributes must be equal: name,
    > parent, isAbstract, and properties.
    > className, userInfo, and validation predicates are not compared.
    >
    > • For each property in each entity, the following attributes must
    > be equal: name, isOptional,isTransient, isReadOnly, for attributes
    > attributeType, and for relationshipsdestinationEntity, minCount,
    > maxCount, deleteRule, and inverseRelationship.
    > userInfo and validation predicates are not compared.
    >
    > (see Core Data Model Versioning and Data Migration Programming Guide
    >> Versioning).
    >
    > Not all this information is maintained in the store, but it *may* be
    > that you managed to get away with something on Tiger that isn't now
    > allowed on Leopard.
    >
    > mmalc

    Aurélien,
    Objective Decision Team
  • On Oct 28, 2007, at 5:45 PM, <cocoalist...> wrote:

    > coordinator = [[NSPersistentStoreCoordinator alloc]
    > initWithManagedObjectModel: [self managedObjectModel]];

    What's the implementation of -managedObjectModel look like?  Is it
    creating a merged model from all frameworks you're using, or is it
    just loading a specific model from your application bundle?

    It should really do the latter, so you don't wind up with extraneous
    entities in the schema for your SQLite persistent store.  Otherwise
    you could wind up with a persistent store that you can't open after
    changing the configuration of your system or on another system.

      -- Chris
  • On Oct 28, 2007, at 11:12 PM, Chris Hanson wrote:

    > On Oct 28, 2007, at 5:45 PM, <cocoalist...> wrote:
    >
    >> coordinator = [[NSPersistentStoreCoordinator alloc]
    >> initWithManagedObjectModel: [self managedObjectModel]];
    >
    > What's the implementation of -managedObjectModel look like?  Is it
    > creating a merged model from all frameworks you're using, or is it
    > just loading a specific model from your application bundle?
    >
    > It should really do the latter, so you don't wind up with
    > extraneous entities in the schema for your SQLite persistent
    > store.  Otherwise you could wind up with a persistent store that
    > you can't open after changing the configuration of your system or
    > on another system.
    >
    > -- Chris
    >

    It seems to be creating a merged model from all frameworks I'm using
    (see below).  And the app does use a lot of frameworks besides the
    standard set.  There's Security, SystemConfiguration, and Message.
    I'm not sure how to load a specific model from my app bundle, but I
    will definitely look into it and see if that helps.

    Thanks,
    Bill

    - (NSManagedObjectModel *)managedObjectModel {
    if (managedObjectModel) return managedObjectModel;

    NSMutableSet *allBundles = [[NSMutableSet alloc] init];
    [allBundles addObject: [NSBundle mainBundle]];
    [allBundles addObjectsFromArray: [NSBundle allFrameworks]];

    managedObjectModel = [[NSManagedObjectModel mergedModelFromBundles:
    [allBundles allObjects]] retain];
    [allBundles release];

    return managedObjectModel;
    }
  • On Oct 29, 2007, at 8:42 AM, Bill wrote:

    > It seems to be creating a merged model from all frameworks I'm using
    > (see below).  And the app does use a lot of frameworks besides the
    > standard set.  There's Security, SystemConfiguration, and Message.
    > I'm not sure how to load a specific model from my app bundle, but I
    > will definitely look into it and see if that helps.
    >
    The message framework at least now contains a model, so this is
    getting merged in.

    In your case, you should probably only load models from your app
    bundle (NSBundle mainBundle):

    managedObjectModel = [[NSManagedObjectModel mergedModelFromBundles:
    [NSBundle mainBundle]] retain];

    mmalc
  • On Oct 29, 2007, at 9:25 AM, mmalc crawford wrote:

    >
    > On Oct 29, 2007, at 8:42 AM, Bill wrote:
    >
    >> It seems to be creating a merged model from all frameworks I'm
    >> using (see below).  And the app does use a lot of frameworks
    >> besides the standard set.  There's Security, SystemConfiguration,
    >> and Message.  I'm not sure how to load a specific model from my
    >> app bundle, but I will definitely look into it and see if that helps.
    >>
    > The message framework at least now contains a model, so this is
    > getting merged in.
    >
    > In your case, you should probably only load models from your app
    > bundle (NSBundle mainBundle):
    >
    > managedObjectModel = [[NSManagedObjectModel
    > mergedModelFromBundles: [NSBundle mainBundle]] retain];
    >
    > mmalc
    >

    That worked!  Is there documentation about the message framework
    containing a model in OS 10.5?  I assume this is because
    NSMailDelivery has been decremented for OS 10.5?  Any suggestions for
    a replacement for NSMailDelivery?

    Thank you for the assistance,
    Bill
  • On Oct 29, 2007, at 9:25 AM, mmalc crawford wrote:
    > In your case, you should probably only load models from your app
    > bundle (NSBundle mainBundle):
    > managedObjectModel = [[NSManagedObjectModel mergedModelFromBundles:
    > [NSBundle mainBundle]] retain];
    >
    For the benefit of the archives, this should obviously be:

    NSArray *bundleArray = [NSArray arrayWithObject:[NSBundle mainBundle]];
    managedObjectModel = [[NSManagedObjectModel mergedModelFromBundles:
    bundleArray] retain];

    mmalc
previous month october 2007 next month
MTWTFSS
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Go to today