<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreData",
  "identifier" : "/documentation/CoreData/NSMigrationManager/migrateStore(from:type:options:mapping:to:type:options:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Data",
      "CoreData"
    ],
    "preciseIdentifier" : "s:So18NSMigrationManagerC8CoreDataE12migrateStore4from4type7options7mapping2toAfGy10Foundation3URLV_So012NSPersistentF0CACE0F4TypeVSDys11AnyHashableVypGSgSo14NSMappingModelCAlpTtKF"
  },
  "title" : "migrateStore(from:type:options:mapping:to:type:options:)"
}
-->

# migrateStore(from:type:options:mapping:to:type:options:)

Migrates the source store to the destination using the specified mapping model.

```
func migrateStore(from sourceURL: URL, type sourceType: NSPersistentStore.StoreType, options sourceOptions: [AnyHashable : Any]? = nil, mapping: NSMappingModel, to destinationURL: URL, type destinationType: NSPersistentStore.StoreType, options destinationOptions: [AnyHashable : Any]? = nil) throws
```

## Parameters

`sourceURL`

The location of the store to migrate.

`sourceType`

The persistent store type of the store you’re migrating from. For possible values, see [`NSPersistentStore.StoreType`](/documentation/CoreData/NSPersistentStore/StoreType).

`sourceOptions`

A dictionary of options to apply to the source store. For possible values, see [`NSPersistentStoreCoordinator`](/documentation/CoreData/NSPersistentStoreCoordinator).

`mapping`

The mapping model that converts the entities in the source store to those in the destination store.

`destinationURL`

The location of the destination store.

`destinationType`

The persistent store type of the store you’re migrating to. For possible values, see [`NSPersistentStore.StoreType`](/documentation/CoreData/NSPersistentStore/StoreType).

`destinationOptions`

A dictionary of options to apply to the destination store. For possible values, see [`NSPersistentStoreCoordinator`](/documentation/CoreData/NSPersistentStoreCoordinator).

## Discussion

A store must exist at `sourceURL`; otherwise, the migration fails. Before the migration occurs, the method ensures compatibility between the source model, the destination model, and the mapping model. If a store doesn’t exist at `destinationURL`, Core Data creates one as part of the migration; otherwise, the migration updates the existing store.

---

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)