Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

core data NSPersistentStore issue

I am developing an application that is rolled out in stages. For each sprint, there are database changes so core data migration has been implemented. So far we have had 3 stage releases. Whenever successive up gradation is done , the application runs fine. But whenever I try to upgrade from version 1 to version 3, 'unable to add persistent store' error occurs'. Can someone help me with the issue ?

like image 519
Mary Avatar asked Apr 28 '14 05:04

Mary


People also ask

What is Nspersistentstore?

The abstract base class for all Core Data persistent stores.

Is Core Data thread safe?

Core Data is designed to work in a multithreaded environment. However, not every object under the Core Data framework is thread safe. To use Core Data in a multithreaded environment, ensure that: Managed object contexts are bound to the thread (queue) that they are associated with upon initialization.

Should I check use Core Data?

The next time you need to store data, you should have a better idea of your options. Core Data is unnecessary for random pieces of unrelated data, but it's a perfect fit for a large, relational data set. The defaults system is ideal for small, random pieces of unrelated data, such as settings or the user's preferences.

What is the purpose of Core Data?

Core Data is a framework that you use to manage the model layer objects in your application. It provides generalized and automated solutions to common tasks associated with object life cycle and object graph management, including persistence.


2 Answers

My problem is i am trying to change my attribute datatype during automatic lightweight migration, as automatic lightweight core data migration does not support data type change. I resolved this issue by resetting the data type to older one.

like image 25
Mary Avatar answered Oct 20 '22 07:10

Mary


Core Data migration does not have a concept of versions as you would expect them. As far as Core Data is concerned there are only two versions, the version of the NSPersistentStore and the version you are currently using.

To use lightweight migration, you must test every version of your store and make sure that it will migrate to the current version directly. If it does not then you cannot use lightweight migration for that specific use case and you either need to develop a migration model or come up with another solution.

Personally, on iOS, I avoid heavy migration as it is very expensive in terms of memory and time. If I cannot use a lightweight migration I most often will explore export/import solutions (exporting to JSON for example and importing in to the new model) or look at refreshing data from the server.

like image 90
Marcus S. Zarra Avatar answered Oct 20 '22 05:10

Marcus S. Zarra