Core Data model configuration incompatible when updating existing entity

ios swift sqlite core-data

295 просмотра

1 ответ

I have a Core Data model which adds a single attribute to an entity. It migrates fine and I can add new objects to that entity without problems. When I attempt to add a new relationship to another object in a different entity however I get this fatal error.

Unresolved error Error Domain=NSCocoaErrorDomain Code=134020 "The model configuration used to open the store is incompatible with the one that was used to create the store." UserInfo={problemObject=<Order: 0x1702a5a00> (entity: Order; id: 0x170431980 <x-coredata:///Order/t38B0CF1D-437E-44AE-B833-D10B5AD584535> ; data: {
    collection = "0xd000000000040004 <x-coredata://D29044CF-B9FB-4D26-9FB3-96FFEE919BD0/Collection/p1>";
    displayOrder = 9999;
    filterUser = "0xd000000000100008 <x-coredata://22E973D7-62F3-4F8F-B85B-CF12DFB8EFD7/FilterUser/p4>";
    quantity = 1;
    size = 1;
}), NSUnderlyingException=Can't resolve how to assign objects to stores; some objects may have been assigned to stores; use [[managedObject objectID] persistentStore] to find out what is going where now; use [managedObjectContext assignObject:toStore:] to straighten things out}, [AnyHashable("problemObject"): <Order: 0x1702a5a00> (entity: Order; id: 0x170431980 <x-coredata:///Order/t38B0CF1D-437E-44AE-B833-D10B5AD5845

If I add a new object to the entity then the relationships to it work fine, in fact the existing relationships on the existing object also work, it's just new ones. I can't for the life of me work out what's going on.

Автор: DanM Источник Размещён: 08.11.2019 11:14

Ответы (1)

0 плюса

Found some of the issue.

I'd moved to the new NSPersistentContainer in iOS 10/ macOS 10.12. It was adding the default configuration by default so even though I was adding my own the new saves were going to "Default" instead of the correct configuration. All works now but only from the second launch as the configuration has the incorrect name the first time round.

Автор: DanM Размещён: 20.08.2016 12:43
Вопросы из категории :