Resolving CoreData error in iPhone Simulator

12 11 2009

I was working on an iPhone application in Xcode. It was the default CoreData table view application. When I tried to build and go, I got and error that told me the model used to access my database was incompatible with the model used to create it.

The error included this bit:

reason = “The model used to open the store is incompatible with the one used to create the store”;

Thanks to some quick, Google-powered research, I was able to find the answer. Every time that you make any data model changes to an iPhone application in development, you need to delete the application from the iPhone simulator or physical device before trying to build the application. When you delete an application on either platform, you delete all of the data associated with it, including the database that uses a now-obsolete data model, which causes Xcode to throw an error.

I am still a rookie software developer, and I have found that Google is not just for finding people with the same name as you. It can be a big help in finding resources and quick solutions. No matter what development issue that you may be having, chances are that someone else has already dealt with it and shared their experience.

Screen shot 2009-11-12 at 8.08.25 PM.png




53 responses

20 04 2010

Thanks for the explanation..

26 04 2010

Not a problem. I am happy that someone was able to get some use out of this post. Cheers!

9 10 2010


1 11 2010

I have run up against the same error but still not able to get past it. I have completely reset the simulator but still no luck.

I have been playing around with one of the code samples from Apple called ‘Recipes’ and was trying to add some additional columns to the database but as soon as I do, even before I begin to reference them in the code, I get this error!

14 03 2012

Hmmmmm…. then you may try to insert the data of the same data type that you have defined in model.

14 12 2010
Zaldy B. N. Bughaw

Thanks Man, this saves me a lot of time and headache. 🙂

4 01 2011

Thanks man !

8 01 2011

Thanks a lot for saving me lots of time…

13 01 2011
Mohammad Bahadur

Hey man, many thanks to you,
i was wasting my time till i found this.

27 01 2011
Kevin McCreary

Thanks. I knew it had to be out there. Just needed to google the exact phrase.

9 02 2011

It’s really a practical solution,
Thank you.

10 02 2011

Happy to help!

17 02 2011
Mark Robinson

Thanks, helped me

15 03 2011

Thanks, very much.
It’s easy to solve really if I know (but hard because I’m a noob).

16 03 2011
roderic campbell

Yes, but what if the app is in production already? How do you do a migration?

23 03 2011

Thanks for this! Really helped out!

2 04 2011

Huge thank’s!

12 05 2011
Van Du

Funny how your blog gave me the solution to this same problem.. lol

we’re looping

27 06 2011
Yasaswy Nagavolu

Thanks a bunch dude.. helped me to solve in a min.. yeah again google helped in redirecting here..

29 06 2011

Thanks for saving my time 🙂

10 07 2011
Maanas Royy

Thanx it saved me lot of time

12 07 2011


22 07 2011

thanks 🙂

6 08 2011

Thanks. Still useful after two years 🙂

13 08 2011

Thanks man

20 08 2011


20 08 2011
Peer Boerner

I see I’m not the only one who ran into this. Many Thanks Indeed!!!!

20 10 2011


27 10 2011

thanks man thought it was my code.

26 11 2011

2 years after and this still does the trick! Thanks man

6 12 2011

i love you!

21 12 2011

Thanks I was having this problem too!

26 12 2011
Sercan Karaoglu

Hi guys, you don’t need remove app. simply it is enough to only delete .sqlite file here below is the code to get this done

NSError *error = nil;
NSURL *applicationDocumentsDirectory = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
NSURL *storeURL = [applicationDocumentsDirectory URLByAppendingPathComponent:@”Model.sqlite”];
[[NSFileManager defaultManager] removeItemAtPath:storeURL.path error:&error];

– (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
[self deleteAllNewsTypesFromDatabase];

28 12 2011

That is a much better solution. I would imagine it really saves some development time. Thanks for sharing!

2 01 2012

I’m thoroughly confused why there is so much praise here. If you are just going to delete the database file and make your customers start over, what is the purpose of versioning your model? This is so you can UPDATE the model structure, not so you can delete it and start over and tell your customer “sorry about your luck.” Or am I just missing the obvious?

2 01 2012

Frankly, I am still surprised that this post has received as much attention as it has. I wrote this about two years ago and I was still learning about iOS development. I still have not produced any production apps, so I was not too worried about deleting customer’s databases. My job takes so much of my time, I have not had much time to devote to iOS development. If you have a suggestion for how to update the model without deleting the database, feel free to post it here.

22 01 2012
Hendrik Ewert

Thank you for this quick and easy solution.
It saves a lot of time for coding.

Nice job, Hendrik

3 02 2012

Thanks. This is a quick way to fix the problem in early stages of development, which some of us need. No idea why some people are so envious that this post is so liked by some …

17 02 2012

saved my lot of time.

2 03 2012

dude.. 3 years later saved my evening ! thanks !

4 04 2012

you’ve been a great help!

10 04 2012

so simple, when you think about it, but of course I did not by myself…
thank you 🙂

20 04 2012

Thank you so much…… really helped me a lot…..

22 05 2012

Wow! I really have to thank you! I have spent hours modifying my database and deleting and recreating classes. I was about to give up, but decided to do a quick google search and I’m extremely glad I did! Worked like a charm! Easiest fix to any problem I’ve ever had, I couldn’t be any more grateful! Thank you!

13 06 2012
Naveen B

Wow! really thank you for your article.

26 06 2012
shyam parmar

i have the same problem but i didn’t use core data.

24 07 2012
nada magdy

Thanks alot , that solved the problem

4 08 2012
gagan g

thank you so much! spent over an hour trying to figure out what was wrong untill I found this.

30 10 2012

this really worked for me..

18 01 2013

Muchas gracias!!!

6 02 2013

Thank you very much!

22 02 2013

Thank’s so much for the help. 🙂

9 05 2013

Thank you soooo much!!!!!
I’m starting with native development in iOS and this was exactly what I needed, Thank you again Bro!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: