Mapping Model created for models that contain a derived attribute don't match entity version hashes

Number:rdar://FB9044112 Date Originated:2020-03-15
Status:Open Resolved:
Product:Xcode Product Version:Version 12.4 (12D4e)
Classification: Reproducible:Always
Xcode create invalid mapping models for Core Data models that have a date derived attribute which derivation expression is `now()`.
For those entities `sourceEntityVersionHash` and `destinationEntityVersionHash` for the mapping doesn’t match the version hash in the source and destination models.

For automatic migrations the mapping model isn’t used because the hashes don’t match.
So I created a sample project with a manual migration which the mapping model is loaded from a specific file or inferred.

When migrating from the mapping model `Persistence.migrationModel = .migrationModel` the migration fails with error: "Mismatch between mapping and source/destination models"

When migrating with inferred model `Persistence.migrationModel = .infered` the migration don’t fail but it isn’t possible to customize it.

As a workaround I create the option `Persistence.migrationModel = .fixedMigrationModel`, which will check if the version hashes don’t match and force them to be equal if the entity have a derived attribute of `Date` type and with derivation expression is `now()`.

The sample project can be found at


The problem also occurs with derived attributes whose derivation expressions are different from now() (i.e. @count)

By alessandromarzoli at April 23, 2021, 10:01 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!