核心数据映射模型无法使用正确的哈希值 [英] Core data mapping model not working with correct hashes

查看:77
本文介绍了核心数据映射模型无法使用正确的哈希值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我决定为我的实体之一创建2个子实体。



要测试我创建的这两个实体没有任何属性,也没有任何关系。



如果我使用推断映射模型,核心数据失败,并且应用程序崩溃。已报告此处



如果我创建映射模型,则核心数据也无法升级。我检查了核心数据日志,它说实体哈希是正确的。
这可能是什么问题?

  CoreData:注释:持久性存储
'文件的不兼容版本架构://localhost/Users/.../StoreContent/persistentStore。
存储元数据= {
NSPersistenceFrameworkVersion = 419;
NSStoreModelVersionHashes = {
Chat =< 05d870d5 8d51e966 51a6b121 56fd0eff 6a35760e 829245ce 38e82724 b511b400> ;;
Contact =< 7f14d6ac 1bf1035e 63208d38 c048c396 d6385a95 3c8aec0b 36fbb86f 293fdb4d>
消息=< 45852277 e01bffe5 a83f71fe 09c20dba 838bb51c 411dc185 56ba4ff1 7b68ba3d> ;;
用户=< 1400bc94 f742db62 91627ea5 883e54a8 104da454 a9a7b073 f1e827ad 26f7e7c8>
};
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers =(
13年7月3日
);
NSStoreType = SQLite;
NSStoreUUID = 73F77A17-9720-4D0E-90DD-D07A0EAECB29;
_NSAutoVacuumLevel = 2; }和当前模型版本= {
广播=< e2afd25a 758f8e8b 7a2e1f2d 03042e32 e5e23693 a4935257 04a8e9fb 535e2452> ;;
Chat =< 05d870d5 8d51e966 51a6b121 56fd0eff 6a35760e 829245ce 38e82724 b511b400> ;;
Contact =< 7f14d6ac 1bf1035e 63208d38 c048c396 d6385a95 3c8aec0b 36fbb86f 293fdb4d> ;;
Group =< 67fa7527 b68ea99d ee8e704f 30f20e48 58350963 73e29c19 8aea7604 dfac7d7c> ;;
消息=< 45852277 e01bffe5 a83f71fe 09c20dba 838bb51c 411dc185 56ba4ff1 7b68ba3d> ;;
用户=< 1400bc94 f742db62 91627ea5 883e54a8 104da454 a9a7b073 f1e827ad 26f7e7c8> }
2013-07-04 10:25:53.678 JonglaIM [90118:22103]
CoreData:批注:(迁移)将尝试自动模式
迁移2013-07-04 10:25: 55.209 x [90118:22103] CoreData:
注释:(迁移)寻找带有源
哈希的映射模型:{
Chat =< 05d870d5 8d51e966 51a6b121 56fd0eff 6a35760e 829245ce 38e82724 b511b400>
Contact =< 7f14d6ac 1bf1035e 63208d38 c048c396 d6385a95 3c8aec0b 36fbb86f 293fdb4d> ;;
消息=< 45852277 e01bffe5 a83f71fe 09c20dba 838bb51c 411dc185 56ba4ff1 7b68ba3d> ;;
用户=< 1400bc94 f742db62 91627ea5 883e54a8 104da454 a9a7b073 f1e827ad 26f7e7c8> }
目的地散列:{
Broadcast =< e2afd25a 758f8e8b 7a2e1f2d 03042e32 e5e23693 a4935257 04a8e9fb 535e2452> ;;
Chat =< 05d870d5 8d51e966 51a6b121 56fd0eff 6a35760e 829245ce 38e82724 b511b400> ;;
Contact =< 7f14d6ac 1bf1035e 63208d38 c048c396 d6385a95 3c8aec0b 36fbb86f 293fdb4d> ;;
Group =< 67fa7527 b68ea99d ee8e704f 30f20e48 58350963 73e29c19 8aea7604 dfac7d7c> ;;
消息=< 45852277 e01bffe5 a83f71fe 09c20dba 838bb51c 411dc185 56ba4ff1 7b68ba3d> ;;
用户=< 1400bc94 f742db62 91627ea5 883e54a8 104da454 a9a7b073 f1e827ad 26f7e7c8> }
2013-07-04 10:25:55.214 x [90118:22103]
CoreData:注释:(迁移)检查路径
file:// localhost / Users /上的映射模型。 ../Model.cdm
源散列:{(
< 1400bc94 f742db62 91627ea5 883e54a8 104da454 a9a7b073 f1e827ad 26f7e7c8>,
< 7f14d6ac 1bff3535e 63208d38 c048c3db4c95b0c3d4b4c3d3b3b3b3b3b3b3b0bb3b0bb3b3b0bfbbfbfbfb7b6b0bbfbfbfbfbfbfbfdfdfdfdfdfdbfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfd b< 05d870d5 8d51e966 51a6b121 56fd0eff 6a35760e 829245ce 38e82724 b511b400>,
< 45852277 e01bffe5 a83f71fe 09c20dba 838bb51c 411dc185 56ba4ff1 7b68ba3e e7b2e4b4e2b4e7b2e4b e7b2e4b e7b2e4b e7b2e2b4e2b4e2b4e2b4e2b4e2b4e2b4e2b4e7b2e2b4e2b4e2b4e2b4e2b4e2b4e2b4e2b4e2b4e2b4e2b4e2b2e4b a4935257 04a8e9fb 535e2452>中
将1400bc94 f742db62 91627ea5 883e54a8 104da454 a9a7b073 f1e827ad 26f7e7c8>中
将7f14d6ac 1bf1035e 63208d38 c048c396 d6385a95 3c8aec0b 36fbb86f 293fdb4d>中
将67fa7527 b68ea99d ee8e704f 30f20e48 58350963 73e29c19 8aea7604 dfac7d7c>,
< 05d870d5 8d51e966 51a6b121 56fd0eff 6a35 760e 829245ce 38e82724 b511b400>,
< 45852277 e01bffe5 a83f71fe 09c20dba 838bb51c 411dc185 56ba4ff1 7b68ba3d> )} 2013-07-04 10:25:55.215 x [90118:22103] CoreData:
批注:(迁移)找不到合适的映射模型


解决方案

现在是2019年,在撰写本文时,Xcode v10.2仍然存在。



我在我的数据模型中添加了一个属性(在新版本中),并希望基于当前属性将一些数据迁移到该模型中,以确保在访问商店时该属性具有值。我创建了一个新的模型版本,添加了属性,然后使用自定义策略创建了实体映射文件以实现此目的。



将我的头撞在墙上一整天后,此处的说明突出显示了解决方法: https://blog.vucica.net/ 2013/04 / core-data-migrating-ignores-manual-mapping-model-or-fails-migration-despite-mapping-models-existence.html



基本上,在Xcode映射模型编辑器中,交换 Source和 Destination模型,然后再次切换回它们。我验证了这实际上是 did 导致的更改,方法是先在更改前进行提交,然后再观察对 xcmapping.xml 文件的细微更改。 / p>

这不是Xcode中的一个愚蠢的错误第一次导致沮丧,这可能不是最后一次。那好吧。向上和向上!


So i decided to create 2 sub entities of one of my entity.

To test i created these 2 entities without any attribute neither relationship.

If i use infer mapping model, core data fails and there is a crash in the app. Reported here

If i create a mapping model, core data can't also upgrade. I checked core data log and it says that the entity hashes are correct. What could be wrong here?

 CoreData: annotation: Incompatible version schema for persistent store
 'file://localhost/Users/.../StoreContent/persistentStore'.
 store metadata = {
     NSPersistenceFrameworkVersion = 419;
     NSStoreModelVersionHashes =     {
         Chat = <05d870d5 8d51e966 51a6b121 56fd0eff 6a35760e 829245ce 38e82724 b511b400>;
         Contact = <7f14d6ac 1bf1035e 63208d38 c048c396 d6385a95 3c8aec0b 36fbb86f 293fdb4d>;
         Message = <45852277 e01bffe5 a83f71fe 09c20dba 838bb51c 411dc185 56ba4ff1 7b68ba3d>;
         User = <1400bc94 f742db62 91627ea5 883e54a8 104da454 a9a7b073 f1e827ad 26f7e7c8>;
     };
     NSStoreModelVersionHashesVersion = 3;
     NSStoreModelVersionIdentifiers =     (
         3July13
     );
     NSStoreType = SQLite;
     NSStoreUUID = "73F77A17-9720-4D0E-90DD-D07A0EAECB29";
     "_NSAutoVacuumLevel" = 2; } and current model versions = {
     Broadcast = <e2afd25a 758f8e8b 7a2e1f2d 03042e32 e5e23693 a4935257 04a8e9fb 535e2452>;
     Chat = <05d870d5 8d51e966 51a6b121 56fd0eff 6a35760e 829245ce 38e82724 b511b400>;
     Contact = <7f14d6ac 1bf1035e 63208d38 c048c396 d6385a95 3c8aec0b 36fbb86f 293fdb4d>;
     Group = <67fa7527 b68ea99d ee8e704f 30f20e48 58350963 73e29c19 8aea7604 dfac7d7c>;
     Message = <45852277 e01bffe5 a83f71fe 09c20dba 838bb51c 411dc185 56ba4ff1 7b68ba3d>;
     User = <1400bc94 f742db62 91627ea5 883e54a8 104da454 a9a7b073 f1e827ad 26f7e7c8>; } 
2013-07-04 10:25:53.678 JonglaIM[90118:22103]
 CoreData: annotation: (migration)   will attempt automatic schema
 migration 2013-07-04 10:25:55.209 x[90118:22103] CoreData:
 annotation: (migration) looking for mapping model with   source
 hashes:  {
     Chat = <05d870d5 8d51e966 51a6b121 56fd0eff 6a35760e 829245ce 38e82724 b511b400>;
     Contact = <7f14d6ac 1bf1035e 63208d38 c048c396 d6385a95 3c8aec0b 36fbb86f 293fdb4d>;
     Message = <45852277 e01bffe5 a83f71fe 09c20dba 838bb51c 411dc185 56ba4ff1 7b68ba3d>;
     User = <1400bc94 f742db62 91627ea5 883e54a8 104da454 a9a7b073 f1e827ad 26f7e7c8>; }  
destination hashes: {
     Broadcast = <e2afd25a 758f8e8b 7a2e1f2d 03042e32 e5e23693 a4935257 04a8e9fb 535e2452>;
     Chat = <05d870d5 8d51e966 51a6b121 56fd0eff 6a35760e 829245ce 38e82724 b511b400>;
     Contact = <7f14d6ac 1bf1035e 63208d38 c048c396 d6385a95 3c8aec0b 36fbb86f 293fdb4d>;
     Group = <67fa7527 b68ea99d ee8e704f 30f20e48 58350963 73e29c19 8aea7604 dfac7d7c>;
     Message = <45852277 e01bffe5 a83f71fe 09c20dba 838bb51c 411dc185 56ba4ff1 7b68ba3d>;
     User = <1400bc94 f742db62 91627ea5 883e54a8 104da454 a9a7b073 f1e827ad 26f7e7c8>; } 
 2013-07-04 10:25:55.214 x[90118:22103]
 CoreData: annotation: (migration) checking mapping model at path
file://localhost/Users/.../Model.cdm
 source hashes:  {(
     <1400bc94 f742db62 91627ea5 883e54a8 104da454 a9a7b073 f1e827ad 26f7e7c8>,
     <7f14d6ac 1bf1035e 63208d38 c048c396 d6385a95 3c8aec0b 36fbb86f 293fdb4d>,
     <05d870d5 8d51e966 51a6b121 56fd0eff 6a35760e 829245ce 38e82724 b511b400>,
     <45852277 e01bffe5 a83f71fe 09c20dba 838bb51c 411dc185 56ba4ff1 7b68ba3d> )}  
destination hashes: {(
     <e2afd25a 758f8e8b 7a2e1f2d 03042e32 e5e23693 a4935257 04a8e9fb 535e2452>,
     <1400bc94 f742db62 91627ea5 883e54a8 104da454 a9a7b073 f1e827ad 26f7e7c8>,
     <7f14d6ac 1bf1035e 63208d38 c048c396 d6385a95 3c8aec0b 36fbb86f 293fdb4d>,
     <67fa7527 b68ea99d ee8e704f 30f20e48 58350963 73e29c19 8aea7604 dfac7d7c>,
     <05d870d5 8d51e966 51a6b121 56fd0eff 6a35760e 829245ce 38e82724 b511b400>,
     <45852277 e01bffe5 a83f71fe 09c20dba 838bb51c 411dc185 56ba4ff1 7b68ba3d> )} 2013-07-04 10:25:55.215 x[90118:22103] CoreData:
 annotation: (migration) no suitable mapping model found

解决方案

It's 2019 now, Xcode v10.2 at the time of writing, and this issue is still relevant.

I added an attribute to my data model (in a new version) and wished to migrate some data to it based on a current attribute to ensure it had a value by the time the store was accessed. I created a new model version, added the attribute, then created the entity mapping file with a custom policy to achieve this.

After banging my head against a wall for an entire day, the instructions here highlighted the fix: https://blog.vucica.net/2013/04/core-data-migrating-ignores-manual-mapping-model-or-fails-migration-despite-mapping-models-existence.html

Basically, in the Xcode Mapping Model editor, swap the "Source" and "Destination" models around, then switch them back again. I verified that this in fact did lead to changes by committing before the change, then observing the slight change to the xcmapping.xml file afterwards.

It's not the first time a silly bug in Xcode has lead to frustration, and it's probably not going to be the last. Oh well. Onwards and upwards!

这篇关于核心数据映射模型无法使用正确的哈希值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆