<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreData",
  "identifier" : "/documentation/CoreData/NSStagedMigrationManager",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Data"
    ],
    "preciseIdentifier" : "c:objc(cs)NSStagedMigrationManager"
  },
  "title" : "NSStagedMigrationManager"
}
-->

# NSStagedMigrationManager

An object that handles the migration event loop and provides access to the migrating persistent store.

```
class NSStagedMigrationManager
```

## Overview

A staged migration manager contains the individual stages of a migration and applies those stages, in the order you specify, when that migration runs. The manager handles the migration’s event loop, and provides access to the migrating store through its [`container`](/documentation/CoreData/NSStagedMigrationManager/container) property. Stages can be custom, which enables you to perform tasks immediately before and after a stage runs, or lightweight, which supplements custom stages with those that Core Data can invoke automatically because they’re already compatible with lightweight migrations.

Use [`NSPersistentStoreStagedMigrationManagerOptionKey`](/documentation/CoreData/NSPersistentStoreStagedMigrationManagerOptionKey) to include an instance of [`NSStagedMigrationManager`](/documentation/CoreData/NSStagedMigrationManager) in your persistent store’s options dictionary, as the following example shows:

```swift
// Create a migration manager with the required stages.
let manager = NSStagedMigrationManager(stages)

let options = [
    // Enable lightweight migrations for this store.
    NSMigratePersistentStoresAutomaticallyOption: true,
    NSInferMappingModelAutomaticallyOption: true
    // Specify the migration manager to use with this store.
    NSPersistentStoreStagedMigrationManagerOptionKey: manager 
]

// Add the store to the persistent store coordinator.        
let store = coordinator.addPersistentStore(
    type: .sqlite,
    at: storeURL,
    options: options
)
```

## Topics

### Creating a migration manager

[`init(_:)`](/documentation/CoreData/NSStagedMigrationManager/init(_:))

Creates a migration manager with the specified stages.

[`-  initWithMigrationStages:`](/documentation/CoreData/NSStagedMigrationManager/initWithMigrationStages:)

Creates a migration manager with the specified stages.

### Accessing the persistent container

[`container`](/documentation/CoreData/NSStagedMigrationManager/container)

The container that provides access to the migrating persistent store.

### Accessing the stages

[`stages`](/documentation/CoreData/NSStagedMigrationManager/stages)

The migration stages.

## Relationships

### Conforms To

[`Equatable`](/documentation/Swift/Equatable)

[`Hashable`](/documentation/Swift/Hashable)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`CVarArg`](/documentation/Swift/CVarArg)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)