Type Method


Returns a newly created mapping model that will migrate data from the source to the destination model.


class func inferredMappingModel(forSourceModel sourceModel: NSManagedObjectModel, destinationModel: NSManagedObjectModel) throws -> NSMappingModel



The source managed object model.


The destination managed object model.


If a problem occurs, on return contains an NSInferredMappingModelError error that describes the problem.

The error’s user info will contain additional details about why inferring the mapping model failed (check for the following keys: reason, entity, property.

Return Value

A newly-created mapping model to migrate data from the source to the destination model. If the mapping model can not be created, returns nil.


A model will be created only if all changes are simple enough to be able to reasonably infer a mapping (for example, removing or renaming an attribute, adding an optional attribute or relationship, or adding renaming or deleting an entity). Element IDs are used to track renamed properties and entities.

See Also

Creating a Mapping

init?(from: [Bundle]?, forSourceModel: NSManagedObjectModel?, destinationModel: NSManagedObjectModel?)

Returns the mapping model that will translate data from the source to the destination model.

init?(contentsOf: URL?)

Returns a mapping model initialized from a given URL.