5

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.

Community
  • 1
  • 1
tly_alex
  • 103
  • 1
  • 9

2 Answers2

5

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

Ashley Mills
  • 50,474
  • 16
  • 129
  • 160
Gougou
  • 387
  • 2
  • 8
  • I had this issue when the new property was added to BaseObject, with all other objects in database inheriting from it. I have created a mapping model as you suggested, and without changing anything in automatically generated file, the migration worked. – Halyna Rubashko Feb 17 '17 at 05:28
-3

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.

Dean Davids
  • 4,174
  • 2
  • 30
  • 44
  • There's no reason migration wouldn't work in the simulator. As far as Core Data goes, it's exactly the same environment. – Tom Harrington May 11 '14 at 23:13
  • If you say so. I remember very early on having that problem in simulator. Have always deleted on change to mom since then. – Dean Davids May 12 '14 at 02:01
  • Migration works fine on simulator after I make sure no property are having the same renaming identifier. – tly_alex May 12 '14 at 04:05