Migration Hash Mismatch

I'm migrating an existing Core Data app to SwiftData and encountering a persistent schema hash mismatch that prevents the store from loading. The Core Data store has been in production for years with version 4 of the model.

I have two models, lets call the Crew and Astronaut Create is a parent in the to-many relationship to Astronaut, the child.

When I try the migration, the Crew model‘s hash matches, but the Astronaut model’s mismatches.

I also tried changing relationship parameters; deleteRule, maximumModelCount, inverse, originalName, and hashModifier. hashModifier changes the hash, but to a third value, so it does not appear to be a way to match the existing Core Data hash.

So, is there a supported way for SwiftData to generate an optional to-one relationship that is Core Data hash-compatible with optional=YES minCount=1 maxCount=1? Or is a migration/rehash/copy step required before SwiftData can adopt this V4 store in place?

We are happy to hear you are migrating your existing Core Data app to SwiftData!

We are interested in how you generated the SwiftData Schema and PersistentModels. The NSManagedObjectModel Editor has an option to generate the SwiftData classes from an existing NSManagedObjectModel. This is the recommended path for Core Data client's to move forward with a SwiftData Schema.

Let us know if that resolves the issue you are seeing, if not, then please visit Feedback Assistant to show us your SwiftData Schema and Core Data NSManagedObjectModel and we can provide further assistance.

Hello … I love the generation capability from Xcode. I generated the Swift models using that, ran into the problem. Tried a few things manually, went back to generated fresh SwiftData models. I also have generated the Core Data classes, and compared that manually to the SwiftData versions.

We are glad you utilized the generation capabilities in Xcode, send us a report via the Feedback Assistant so that we can compare the two for the skew in hashes and possibly provide a workaround.

Migration Hash Mismatch
 
 
Q