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.

Core Data Multiple NSEntityDescriptions claim the NSManagedObject subclass
 
 
Q