Context:
- app using CoreData
- some lightweight migration successfully performed in the past (reached the 4th iteration of the model version)
- client wants a new feature
- created a 5th model version
- added one single lousy new property, a non-optional boolean called new_one, to the TestModel entity
The outcome:
CoreData: error: NSUnderlyingError = "Error Domain=NSCocoaErrorDomain Code=134110 \"An error occurred during persistent store migration.\"
UserInfo={
entity= TestModel,
attribute=new_one,
reason=Validation error missing attribute values on mandatory destination attribute}";
}
Solution:
I don't completely grasp why this happens (I'm too tired and eager to leave this problem behind), but the "mandatory destination attribute" thing pointed me in the direction of setting the property as an optional. Whether it's the right thing to do or just an ordinary hack...I don't know...but it solved my problem, I can now move on to the next
NSPersistentContainer.loadPersistentStores
call withCode=134110
andUserInfo={entity=MyEntity, attribute=myNewAttribute, reason=Validation error missing attribute values on mandatory destination attribute}
. This happens right after a successful migration. – Georgeta