views:

102

answers:

3

Hi

I am currently playing with CoreData and have a problem with the CoreDataBooks Example from Apple.

Basically I just wanted to extend the data model. I updated the model class aswell and no compiler error, butr a crash when I want to start the example.

Unresolved error Error Domain=NSCocoaErrorDomain Code=134130 UserInfo=0x1316ce0 "Operation could not be completed. (Cocoa error 134130.)", { URL = file://localhost/.../CoreDataBooks.sqlite; ...some nonsense info ... reason = "Can't find model for source store"; }

Do I need to updat the sqlite database ?

Thanks

A: 

Whenever you modify or update the data model, make sure you:

  1. Add NSManagedObject class header and implementations for any new or modified entities (select the entity in the data modeler and use New File... > NSManagedObject to create new class files).

  2. Delete your app from the iPhone simulator or device, before rebuilding and reinstalling. You can worry about migration issues later.

Alex Reynolds
I am not sure what you mean with the NSManagedObject. I created a "Managed Object Class" form the Entity I changed, so nothing should break there, I also delete the app from the device, but that can not really be the solution when I want to update my app in the future.
eemceebee
Until you write migration routines, the schema of your device/Simulator database will be different from the schema of your modified data model. If you try to run your application with the old database and the new data model, you will get an exception due to the inconsistency between the two. Deleting the application from the device/Simulator is probably the easiest way to manage testing between data model updates, until you're ready to write migration routines.
Alex Reynolds
well unfortunately deleting the app doesnt work either
eemceebee
A: 

Anyway, I needed to version the datamodel before changing anything that would ensure that the model does migrate automatically.

eemceebee
A: 

I tried to do the same thing, what do you mean by "version" the datamodel?

Seraphin