CoreData in Swift throws One-to-Many error

33 Views Asked by At

I have a project using CoreData that uses a schema that has been stable for some time.

in an area that I have been modifying, an entity called Answer looks like this:

enter image description here

So, only a container for relationships. Until recently, the answeredBy relationship was allowed multiple Members to answer a given question. But now, instead, only one Member provides an answer. However, a circumstance can arise where two Members answer as a team. In this case, two Answers are generated at the same time.

So, a Member has many Answers where they are the unique answerer, but Answers have only one Member as answeredBy.

enter image description here

This kind on one-to-many seems totally unproblematic, but Swift refuses to compile now, with this error:

VideoMentor/AppDelegate.swift:58: Fatal error: Unresolved error Error Domain=NSCocoaErrorDomain Code=134140 "Persistent store migration failed, missing mapping model." UserInfo={sourceModel=(<NSManagedObjectModel: 0x6000021208c0>) isEditable 0, entities {
    Answer = "(<NSEntityDescription: 0x6000035106e0>) name Answer, managedObjectClassName NSManagedObject, renamingIdentifier Answer, isAbstract 0, superentity name (null), 
properties {\n    answeredBy = \"(<NSRelationshipDescription: 0x600003311a40>), name answeredBy, isOptional 1, isTransient 0, entity Answer, renamingIdentifier answeredBy, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, destination entity Member, inverseRelationship answerer, minCount 0, maxCount 0, isOrdered 0, deleteRule 1\";\n    
challenge = \"(<NSRelationshipDescription: 0x6000033110e0>), name challenge, isOptional 1, isTransient 0, entity Answer, renamingIdentifier challenge, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, destination entity Challenge, inverseRelationship answer, minCount 0, maxCount 1, isOrdered 0, deleteRule 1\";\n    
team = \"(<NSRelationshipDescription: 0x600003311900>), name team, isOptional 1, isTransient 0, entity Answer, renamingIdentifier team, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, destination entity Team, inverseRelationship answers, minCount 0, maxCount 1, isOrdered 0, deleteRule 1\";\n 
   videos = \"(<NSRelationshipDescription: 0x6000033115e0>), name videos, isOptional 1, isTransient 0, entity Answer, renamingIdentifier videos, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, destination entity Video, inverseRelationship teamAnswer, minCount 0, maxCount 0, isOrdered 0, deleteRule 2\";\n}, subentities {\n}, userInfo {\n}, versionHashModifier (null), uniquenessConstraints (\n        (\n        challenge,\n        team\n    )\n)";

I am confused. Have checked code for any inappropriate calls to relationships, haven't found any, and no errors are thrown in that direction I've found.

I kind of loathe the wearing oven mitts feeling of working with CoreData, but I'm stuck with it. Any insights?

0

There are 0 best solutions below