Question

I try to migrate my Core Data Model with a mapping model. It seems to find the mapping model and actually get pretty far in the migration, but I'm not sure. However, in the end it fails with a generic error and I have no clue what is actually going wrong.

Am I missing the cause of the error in the log, and if so, what is the cause?

Was it helpful?

Solution

You're getting validation failures. As you've probably figured out, Core Data

  1. Figures out that it needs to migrate the persistent store
  2. Finds an appropriate mapping model, FourToFive.cdm
  3. Begins the migration

Later on it fails, though. The errors are not generic-- they're quite specific. They all look like this (wrapped for readability):

"Error Domain=NSCocoaErrorDomain Code=1570 \"The operation couldn\U2019t be completed.
    (Cocoa error 1570.)\" UserInfo=0x10a747bb0 {NSValidationErrorKey=startDate,
    NSLocalizedDescription=The operation couldn\U2019t be completed. (Cocoa error 1570.),
    NSValidationErrorObject=<NSManagedObject: 0x10a7380f0> (entity: TimeEntry; id:
    0xd00000000008000e <x-coredata://FB4CCC6C-6EB7-44DB-A3F2-F64E23C64827/TimeEntry/p2> ;
    data: <fault>)}",

What this says is that

  • You have a validation failure (because NSValidationErrorKey and NSValidationErrorObject)
  • This error is on the TimeEntry entity
  • The error is specifically caused by the startDate attribute.
  • The validation error is 1570, which is NSValidationMissingMandatoryPropertyError (see Core Data Constants Reference in the docs for this).

So: The new version of TimeEntry appears to have a non-optional attribute called startDate, but in exactly five cases you appear to be migrating a nil value for that attribute. Easy fixes for this would include making the attribute optional or setting a default value in the data model. But you can't add a mandatory attribute and not assign some value for it.

There's also a message about Failed to delete support directory for store that I don't completely understand. The fact that the migration proceeds after that message suggests that it's not your problem, and in any case your errors don't stem directly from that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top