Core Data Multiple NSEntityDescriptions claim the NSManagedObject subclass

Hello everyone,

I'm trying to adopt the new Staged Migrations for Core Data and I keep running into an error that I haven't been able to resolve.

The error messages are as follows:

warning: Multiple NSEntityDescriptions claim the NSManagedObject subclass 'Movie' so +entity is unable to disambiguate.
warning:  	 'Movie' (0x60000350d6b0) from NSManagedObjectModel (0x60000213a8a0) claims 'Movie'.
error: +[Movie entity] Failed to find a unique match for an NSEntityDescription to a managed object subclass

This happens for all of my entities when they are added/fetched. Movie is an abstract entity subclass, and it has the error error: +[Movie entity] Failed to find which is unique to the subclass entities, but this occurs for all entities.

The NSPersistentContainer is loaded only once, and I set the following option after it's loaded:

storeDescription.setOption(
    [stages],
    forKey: NSPersistentStoreStagedMigrationManagerOptionKey
)

The warnings and errors only appear after I fetch or save to context. It happens regardless of whether the database was migrated or not. In my test project, using the generic NSManagedObject with NSEntityDescription.insertNewObject(forEntityName: "MyEntity", into: context) does not cause the issue. However, using the generic NSManagedObject is not a viable option for my app.

Setting the module to "Current Project Module" doesn't change anything, except that it now prints "claims 'MyModule.Show'" in the warnings. I have verified that there are no other entities with the same name or renameIdentifier.

Has anyone else encountered this issue, or can offer any suggestions on how to resolve it?

Thanks in advance for any help!

I've made a mistake while writing here and replaced my function that returns the NSStagedMigrationManager with only [stages]. It should have been NSStagedMigrationManager(stages). This is only an issue in the post and not in my code.

Would you mind to provide a minimal project with detailed steps to reproduce the issue? I'll be intersted in taking a look. Your post can contain a link to where your test project is hosted.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

I've created a sample project on GitHub that demonstrates exactly what's happening with the Staged Migrations warning: Sample project

Thanks for sharing the project, which does reproduce the issue.

It seems to me that the issue is triggered because NSStagedMigrationManager and NSPersistentContainer load the same models into separate Core Data stacks, which leads to a conflict.

Avoiding using APIs that call +entity under the hood eliminates the warnings. For example, using insertNewObject to create the new object, as shown below, fixes the issue in your demo app:

//let entity = MyEntity(context: context)
let entity = NSEntityDescription.insertNewObject(forEntityName: "MyEntity", into: context) as! MyEntity
entity.name = name
try context.save()

However, this doesn't reflect the best practices of using strong types, nor is it practical for a real-world project because there are other Core Data APIs using +entity under the hood.

I'd hence suggest that you file a feedback report for the Core Data folks to take a look – If you do so, please share your report ID here for folks to track.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

@DTS Engineer I've filed feedback detailing this issue, including links to both this thr ead and the sample project.

FB18334791

Hi everyone!

Is there an update on this issue or the posted feedback? I still run into the same in with the Xcode 25.5 RC and iOS 26.5 RC.

What I do is:

  1. Rename the first model from Model to ModelV1
  2. Copy the ModelV1 to ModelV2
  3. Add new properties in ModelV2
  4. Create NSStagedMigrationManager

All entities are with manual/none generation.

As I've already introduced usage of into: context when creating new objects, they are fine.

Now the @FetchRequests fail (the one the views) with: Thread 1: "executeFetchRequest:error: A fetch request must have an entity.". These are 'solvable' by creating a FetchRequest with an entity: https://developer.apple.com/documentation/swiftui/fetchrequest/init(entity:sortdescriptors:predicate:animation:). However this requires passing around the context and adding inits in a lot of places.

These are two WWDC meetings with more info:

  1. https://developer.apple.com/videos/play/wwdc2023/10186
  2. https://developer.apple.com/videos/play/wwdc2022/10120

However they don't contain clues what might be needed.

Core Data Multiple NSEntityDescriptions claim the NSManagedObject subclass
 
 
Q