---
title: "associate(sourceInstance:withDestinationInstance:for:)"
framework: coredata
role: symbol
role_heading: Instance Method
path: "coredata/nsmigrationmanager/associate(sourceinstance:withdestinationinstance:for:)"
---

# associate(sourceInstance:withDestinationInstance:for:)

Associates a given source managed object instance with an array of destination instances for a given property mapping.

## Declaration

```swift
func associate(sourceInstance: NSManagedObject, withDestinationInstance destinationInstance: NSManagedObject, for entityMapping: NSEntityMapping)
```

## Parameters

- `sourceInstance`: A source managed object.
- `destinationInstance`: The destination manage object for sourceInstance.
- `entityMapping`: The entity mapping to use to associate sourceInstance with the object in destinationInstances.

## Discussion

Discussion Data migration is performed as a three-stage process (first create the data, then relate the data, then validate the data). You use this method to associate data between the source and destination stores, in order to allow for relationship creation or fix-up after the creation stage. This method is called in the default implementation of NSEntityMigrationPolicy’s createDestinationInstances(forSource:in:manager:) method.

## See Also

### Managing Sources and Destinations

- [destinationInstances(forEntityMappingName:sourceInstances:)](coredata/nsmigrationmanager/destinationinstances(forentitymappingname:sourceinstances:).md)
- [sourceInstances(forEntityMappingName:destinationInstances:)](coredata/nsmigrationmanager/sourceinstances(forentitymappingname:destinationinstances:).md)
