iosswiftxcodecore-datacore-data-migration

Core Data. "reason" : "Can\'t find mapping model for migration while saveContext()


I am trying to save a simple record in my core data entity. but, I keep getting reason=Can't find mapping model for migration exception in the runtime.

These are y core data properties in the Note entity.

@NSManaged public var noteID: String?
@NSManaged public var createdAt: Date?
@NSManaged public var updatedAt: Date?
@NSManaged public var noteDescription: String?
@NSManaged public var noteTitle: String?
@NSManaged public var location: String?

codegen is set to

Manual/None

I set all my attributes to their default values in xcdatamodelid file. I tried deleting data models and recreated them. Still no luck.


Solution

  • You can solve the problem by removing all core data files from Xcode, reading them, and setting the source and destination of the mapping model again.

    You can follow these links:-

    Core Data Migration - Can't find mapping model for migration

    or

    How to manage object model migration:-

    https://www.informit.com/articles/article.aspx?p=2469048&seqNum=4