Re: Core Data Migration Exception
Re: Core Data Migration Exception
- Subject: Re: Core Data Migration Exception
- From: Steve Steinitz <email@hidden>
- Date: Fri, 4 Jan 2008 00:26:53 +1100
Hello,
On 2/1/08, Diederik Hoogenboom wrote:
> The problem might be that your old pre-Xcode 3 model doesn't have any
> version metadata. The migration manager needs to know the versions of
> both the models in order to apply the mapping.
I thought Core Data created a version hash that identified the model.
Is that only for newer stores?
> A possible solution is to manually call migrateStoreFromURL <snip> in case
> the model doesn't have a version.
Thanks Diederik.
Can anyone confirm Diederik's supposition before I jump in with his suggestion?
And, just to clarify, if Diederik is correct, is it the the model or the
store that needs the metadata? If the model, isn't that easily fixed?
If the store, well, that's harder.
Thanks,
Steve
> >I would like to play with Core Data's new Leopard migration tools on a
> >application I've been developing over the past year. However, the
> >default migration code is throwing an exception.
> >
> >The app was created in Xcode 2 but is now an Xcode 3, Leopard-only
> >project. I mention that in case there is anything special about
> >migrating older Core Data Models. I saw something to that effect on
> >another list but don't think that's my current issue.
> >
> >Here are the steps to reproduce the exception. After reading the
> >Versioning and Migration Programming Guide I
> >
> >1. used Xcode's Design menu to add a new model and then
> >
> >2. added an new attribute to an entity.
> >
> >3. I used the Design menu to create a Mapping Model.
> >
> >4. In the code, I modified the default Model creation method,
> > -managedObjectModel, by adding
> >
> > NSMigratePersistentStoresAutomaticallyOption YES
> >
> >to the storeOptions dictionary argument of addPersistentStoreWithType
> >
> >5. I further modified the -managedObjectModel code to avoid the error
> >
> > 'Can't merge models with two different entities named ...'
> >
> >I now use NSManagedModel's -initWithContentsOfUrl to create the Model
> >rather than one of its more convenient model-merging class methods.
> >On a side issue, that was fiddly to get right and remains fragile --
> >I might put details in another thread.
> >
> >Finally,
> >
> >6. I used Xcode's Design menu to set the new, changed Model to be the
> > default Model then
> >
> >7. cleaned, built and ran the app.
> >
> >The app tried valiantly to start the migration but threw:
> >
> > NSInternalInconsistencyException
> > Model already contains an entity named Bike.
> > (full trace below)
> >
> >I don't think there is anything special about the Bike entity nor was
> >it the one I changed -- its likely just the first one the migration
> >process encountered.
> >
> >Thanks for any guidance,
> >
> >Steve
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden