1

I have created a Mac application for the app store - and now find it necessary to modify my 'model' file for Core Data. In my experience, changing this model creates an error upon opening an old file (document based app) that is tied to the old model. I had read in the Apple Documentation that you can prevent this by keeping the old model "versioned" and then creating the new one (I may be mistaken) - does anyone have any tips on this? I'd hate to get a bunch of angry emails from people who can't open their files. Thanks in advance!

Zach

westsider
  • 4,967
  • 5
  • 36
  • 51
Zakman411
  • 1,764
  • 3
  • 22
  • 45
  • You might wish to check [this thread](https://stackoverflow.com/questions/2310216/implementation-of-automatic-lightweight-migration-for-core-data-iphone). It describes in detail how to do the automatic lightweight migration. I implemented it in my app according to this description as well. – Axel Jan 31 '11 at 08:10
  • I should have specified - my app is for Mac. This thread won't be relevant? – Zakman411 Jan 31 '11 at 08:12
  • I'm note sure if that is specific to the iPhone. Have you checked the documentation on lightweight migration? For me, it looked as if it was applicable for the mac as well, but I may be wrong. – Axel Jan 31 '11 at 09:27
  • Check out this blog post by Mathieu Cormer which explains it well. http://www.preenandprune.com/cocoamondo/?p=468 – Joshua Jan 31 '11 at 10:36

1 Answers1

3

You might want to check out: Core Data Model Versioning and Data Migration Programming Guide

What you seem to be looking for is "Lightweight Migration".

There are some tips in that documentation:

  • when adding new attributes these must be defined as optional
  • Renaming items or attributes you need to specify the renaming identifier
  • ...
Christian Beer
  • 2,027
  • 15
  • 13