---
title: "inferredMappingModel(forSourceModel:destinationModel:)"
framework: coredata
role: symbol
role_heading: Type Method
path: "coredata/nsmappingmodel/inferredmappingmodel(forsourcemodel:destinationmodel:)"
---

# inferredMappingModel(forSourceModel:destinationModel:)

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

## Declaration

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

## Parameters

- `sourceModel`: The source managed object model.
- `destinationModel`: The destination managed object model.

## Mentioned in

Migrating your data model automatically

## Return Value

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.

## Discussion

Discussion 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:forSourceModel:destinationModel:)](coredata/nsmappingmodel/init(from:forsourcemodel:destinationmodel:).md)
- [init(contentsOf:)](coredata/nsmappingmodel/init(contentsof:).md)
