0
votes

I am using core data encryption and the current version of my app in Appstore is with encrypted db. Now i am planning to release new version of my application with new entity modification. But while doing lightweight migration i am facing entity name mismatch issue and system fails to match the model and db and hence the operation fails.

My findings are below: While encryption the entity name got renamed by adding a prefix to that.

So if the entity name is "Country", the actual result will be "abcCountry" in db.

While light weight migration, model has the entity name "Country" and it fails to match with the entity names in old version db.

What is the solution. Do i need to rename my entity names in new version.

1

1 Answers

0
votes

In order to do lightweight migration, core data must be able to infer the model mapping.

If you rename an entity, it has no way to tell whether the "new" attribute was added or renamed.

Thus, you have to inform core data that an attribute has been renamed by setting its renamingIdentifier.

In your case, if you renamed an attribute from "Country" to "abcCountry" then you need to modify the "destination model" and set the renamingIdentifier on the new "abcCountry" attribute to "Country" so it can infer the appropriate mapping.

Apple's documentation on this is pretty easy to follow.