Learn Courses My Dashboard

"An error occurred during persistent store migration."


I was working on a project and the simulator was working fine earlier today but now whenever I run it I get the following fatal error in the PersistenceController:

Fatal error: Unresolved error Error Domain=NSCocoaErrorDomain Code=134110 “An error occurred during persistent store migration.”

reason=Cannot migrate store in-place: Validation error missing attribute values on mandatory destination attribute, destinationURL=fil

One thing I know I was doing was making changes to attribute names and types within the managed object subclasses, so in case that caused the problem I deleted those class files and then recreated them, but that didn’t seem to help.

I tried restarting Xcode and my computer, cleaning the build folder, and deleting derived data but I’m still getting the error. Could you tell me what usually causes this and what I could do to fix it?


When you make a change to the names of any properties in the Core Data .xcdatamodeldl file, you will need to either recreate the NSManagedObject subclasses or manually update those files where the names have been changed.

It’s a bit deadly changing property names in the `.xcdatamodeld. file and then forgetting to re-create the subclasses. Xcode will complain bitterly.

Okay I had tried recreating those subclasses earlier without changing the class name and that didn’t work, but after trying again with a name change that did the trick. So once it gets caught with that issue, is that original class name just never usable again after that or is there a way to clean that somehow?

Hi Chris,

I’m not quite sure what you mean here.

If you mean the original Subclasses that were generated? What you should do is delete them manually by selecting the files and hit the delete key. If you don’t get rid of them they will cause a whole lot of confusion.

Right I deleted those original subclass files and then recreated them, but doing that alone didn’t stop the fatal errors. I had to also change the name of the entity/subclass name when recreating, so I changed it from “PersonProfile” to “PersonProfile1”. What I am wondering now is if there is any way to clean the attributes of the original “PersonProfile” entity so that is no longer corrupted and producing those fatal errors. Otherwise, any time I make changes to properties within the entity in the future, I will have to change the name of the entity as well, correct?



Hey Chris,

Are there any mismatching references in your Persistence.swift file which contains your PersistenceController?

You could delete the core data file ( Filename.xcdatamodeld) and then add it in again via the Xcode menu - File > New then scroll down till you see Core Data and select Data Model as in the attached screenshot.

I’ll give that a try if the problem pops up again. Thank you!