Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Core Data lightweight migration error

I have been trying to get the core data lightweight migration working. Ran into an very difficult issue. I have setup up automatic lightweight migration exactly like the documents and other SO posts. And then I create a new version, select it as current, add a new field to some entity, and then ran. Got error:

migration failed with error Error Domain=NSCocoaErrorDomain Code=134140 "The operation couldn’t be completed. (Cocoa error 134140.)" UserInfo=0xce08c10 {reason=Can't find or automatically infer mapping model for migration,

One more error:

NSUnderlyingError = "Error Domain=NSCocoaErrorDomain Code=134190 \"The operation couldn\U2019t be completed. (Cocoa error 134190.)\" UserInfo=0xcdf2d00 {reason=Each property must have a unique renaming identifier}";

I have googled for "Each property must have a unique renaming identifier" for a while and found no result at all.

From the meaning of this error message, the properties should have unique renaming identifier. I go back to my model setting and found that I did have some renaming identifier exactly same.

My question is I didn't really change the model name at all. I just add a new field. I thought renaming identifier will only be useful when trying to renaming something. Or maybe it's required no matter what. If that's the case, then why XCode doesn't give us any warning or error about it? shouldn't it be very obvious for XCode to see?

Any suggestion is welcome.

like image 716
tly_alex Avatar asked Nov 01 '22 00:11

tly_alex


1 Answers

Answering to a post from the past, but you are not the only one who encountered this Can't find or automatically infer mapping model for migration problem.

So, I had the same problem, on a big project with 12 model versions, and only lightweight migrations. Just had 2 properties renamed, and everything was ok until today.

The only fix I found was to add a mapping model (New File => Core Data => Mapping Model ) to my project between my 2 last model versions. I hope I won't have to add one for each new model update. Seems to be a migration bug in Core Data to me.

Hope this will help other people struggling with this error.

But happened on both iOS 8 / iOS 9 devices

like image 156
Gougou Avatar answered Nov 15 '22 07:11

Gougou