---
title: "begin(_:with:)"
framework: coredata
role: symbol
role_heading: Instance Method
path: "coredata/nsentitymigrationpolicy/begin(_:with:)"
---

# begin(_:with:)

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

## Declaration

```swift
func begin(_ mapping: NSEntityMapping, with manager: NSMigrationManager) throws
```

## Parameters

- `mapping`: The mapping object in use.
- `manager`: The migration manager performing the migration.

## Discussion

Discussion This method is the precursor to the creation stage. In a custom class, you can implement this method to set up any state information that will be useful for the duration of the migration.

## See Also

### Related Documentation

- [Core Data Model Versioning and Data Migration Programming Guide](apple-archive/documentation/Cocoa/Conceptual/CoreDataVersioning/Articles/Introduction.html.md)

### Customizing Stages of the Mapping Life Cycle

- [createDestinationInstances(forSource:in:manager:)](coredata/nsentitymigrationpolicy/createdestinationinstances(forsource:in:manager:).md)
- [endInstanceCreation(forMapping:manager:)](coredata/nsentitymigrationpolicy/endinstancecreation(formapping:manager:).md)
- [createRelationships(forDestination:in:manager:)](coredata/nsentitymigrationpolicy/createrelationships(fordestination:in:manager:).md)
- [endRelationshipCreation(forMapping:manager:)](coredata/nsentitymigrationpolicy/endrelationshipcreation(formapping:manager:).md)
- [performCustomValidation(forMapping:manager:)](coredata/nsentitymigrationpolicy/performcustomvalidation(formapping:manager:).md)
- [end(_:manager:)](coredata/nsentitymigrationpolicy/end(_:manager:).md)
