0

I've developed Core Data store using ABC.xcdatamodel. Distributed the app version 1.

Needed to make some simple changes to attribute names, so I created a new version ABC 2.vcdatamodel. Distributed the app version 2. That worked fine. Migration was perfect.

Then, I needed to make a few more simple changes (added one attribute) so I created another new version based on ABC 2; ABC 3.xcdatamodel. Automatic migration fails when updating from version 2.

HOWEVER, if I try to upgrade from a version 1 build (using ABC.xcdatamodel) everything works like a charm.

Am I missing something obvious? Ideas?

mputnamtennessee
  • 372
  • 4
  • 14

1 Answers1

0

One idea - you may have inadvertently modified your version 2 data model making it no longer match the version 2 stores that were created before it was modified. Now when an instance with a "real" version 2 store loads, a matching data model can't be found so it can't translate from 2 to 3. Did you check in your version 2 model to git/svn before working on version 3? Does it show as modified?

Note that "modified" doesn't necessarily mean adding any properties - just any little thing that would change the hash value that Core Data uses to define versions.

David Ravetti
  • 2,030
  • 1
  • 17
  • 22
  • Right you are! I discovered that I had mis-renamed a relationship from "Proposal" to "Proposals." Found this by outputing the hash values to the console. Added the name mapping and all worked as expected. Thanx. – mputnamtennessee Feb 28 '13 at 10:35
  • I've been wrestling with Core Data migration issues myself, and this one has bit me a few times. For your bag of tricks, take a look at this post about turning on Core Data Migration Debug. I just used it and it was a great help identifying exactly which hashes weren't matching. I added a link to a relevant Apple Technote to the selected answer: http://stackoverflow.com/questions/12835950/ – David Ravetti Feb 28 '13 at 22:32