<!--
{
  "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/NSEntityMigrationPolicy",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Data"
    ],
    "preciseIdentifier" : "c:objc(cs)NSEntityMigrationPolicy"
  },
  "title" : "NSEntityMigrationPolicy"
}
-->

# NSEntityMigrationPolicy

A policy instance that customizes the migration process for an entity mapping.

```
class NSEntityMigrationPolicy
```

## Overview

You set the policy for an entity mapping by passing the name of the migration policy class as the argument to [`entityMigrationPolicyClassName`](/documentation/CoreData/NSEntityMapping/entityMigrationPolicyClassName). Typically, you specify the name in the Xcode mapping model editor.

## Topics

### Customizing Stages of the Mapping Life Cycle

[`begin(_:with:)`](/documentation/CoreData/NSEntityMigrationPolicy/begin(_:with:))

Sets up state information before the start of a given entity mapping.

[`createDestinationInstances(forSource:in:manager:)`](/documentation/CoreData/NSEntityMigrationPolicy/createDestinationInstances(forSource:in:manager:))

Creates the destination instance(s) for a given source instance.

[`endInstanceCreation(forMapping:manager:)`](/documentation/CoreData/NSEntityMigrationPolicy/endInstanceCreation(forMapping:manager:))

Indicates the end of the instance creation stage for the specified entity mapping, and the precursor to the next migration stage.

[`createRelationships(forDestination:in:manager:)`](/documentation/CoreData/NSEntityMigrationPolicy/createRelationships(forDestination:in:manager:))

Constructs the relationships between the newly-created destination instances.

[`endRelationshipCreation(forMapping:manager:)`](/documentation/CoreData/NSEntityMigrationPolicy/endRelationshipCreation(forMapping:manager:))

Indicates the end of the relationship creation stage for the specified entity mapping.

[`performCustomValidation(forMapping:manager:)`](/documentation/CoreData/NSEntityMigrationPolicy/performCustomValidation(forMapping:manager:))

Provides the option to perform custom validation on migrated objects during the validation stage of the entity migration policy.

[`end(_:manager:)`](/documentation/CoreData/NSEntityMigrationPolicy/end(_:manager:))

Performs cleanup at the end of the migration, from any phase of the mapping.

### Constants

[`NSMigrationManagerKey`](/documentation/CoreData/NSMigrationManagerKey)

Key for the migration manager.

[`NSMigrationSourceObjectKey`](/documentation/CoreData/NSMigrationSourceObjectKey)

Key for the source object.

[`NSMigrationDestinationObjectKey`](/documentation/CoreData/NSMigrationDestinationObjectKey)

Key for the destination object.

[`NSMigrationEntityMappingKey`](/documentation/CoreData/NSMigrationEntityMappingKey)

Key for the entity mapping object.

[`NSMigrationPropertyMappingKey`](/documentation/CoreData/NSMigrationPropertyMappingKey)

Key for the property mapping object.

[`NSMigrationEntityPolicyKey`](/documentation/CoreData/NSMigrationEntityPolicyKey)

Key for the entity migration policy object.



---

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)