<!--
{
  "availability" : [
    "iOS: 3.0.0 -",
    "iPadOS: 3.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.5.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreData",
  "identifier" : "/documentation/CoreData/NSMigrationManager/associate(sourceInstance:withDestinationInstance:for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Data"
    ],
    "preciseIdentifier" : "c:objc(cs)NSMigrationManager(im)associateSourceInstance:withDestinationInstance:forEntityMapping:"
  },
  "title" : "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.

```
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

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:)`](/documentation/CoreData/NSEntityMigrationPolicy/createDestinationInstances(forSource:in:manager:)) method.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)