How do you clean Core Data generated models and code from a project?

Posted by Hazmit on Stack Overflow See other posts from Stack Overflow or by Hazmit
Published on 2010-04-08T02:39:15Z Indexed on 2010/04/08 2:43 UTC
Read the original article Hit count: 701

Filed under:
|
|

I'm having an extremely annoying problem with Core Data in the iPhone SDK. I would say in general Core Data for the most part appears easy to use and nice to implement.

I have a sqlite database that is being used as a read only reference to pull data elements out for an iPhone app. It would seem there are really mysterious issues relating to what seems to be migration of the database to the most recent versions of my schema.

Why can't you just clean out your stored objects and models and let a project redo all of it when you compile next? You would think if you setup a stored object model there would be a way to just reset it and recompile. I've tried what feels like a thousand 'tips' that have been the results of hours of google searches and documentation prowling to figure out how to do this.

My most recent error during compile time is below.

2010-04-07 18:23:51.891 PE[1962:207] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't merge models with two different entities named 'PElement''

All of this code has been working in the simulator and is only causing me troubles now because I made a change to the schema. I also have the database options for automatically migrating set as below.

NSMutableDictionary *optionsDictionary = [NSMutableDictionary dictionary];
[optionsDictionary setObject:[NSNumber numberWithBool:YES] 
    forKey:NSMigratePersistentStoresAutomaticallyOption];

[optionsDictionary setObject:[NSNumber numberWithBool:YES]
    forKey:NSInferMappingModelAutomaticallyOption];

© Stack Overflow or respective owner

Related posts about core-data

Related posts about iphone-sdk