5
votes

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.

2
simulator or device testing?Dean Davids
Could you tell me exactly what you did to fix this problem? I'm facing the same issue and have no idea what causes it.JakeP
If I remember correctly, you need to make sure that no property are haing the same renaming identifier.tly_alex
You should clean the previous build before running with the modified version.raheel

2 Answers

5
votes

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

-3
votes

I don't believe migration works on the simulator. I always have to delete the app from simulator and start over after making changes to the managed object model.

Test install on a device, which is already set up with the older version, to be sure your migration is successful.