我正在嘗試執行需要MappingModel的iOS Core Data遷移。由於某些原因,核心數據無法使用映射模型,並且它會回到自動輕量級遷移。找不到適用於核心數據遷移的合適映射模型
我啓用了MigrationDebug選項來獲取更多信息,而我所看到的沒有意義。映射模型的源哈希和目標哈希是相同的,忽略順序,源和目標ManagedObjectModels。看來應該使用映射模型,但是日誌說「找不到合適的映射模型」。
這裏是(省略掉)日誌:
CoreData: annotation: (migration) will attempt automatic schema migration
CoreData: annotation: (migration) looking for mapping model with
source hashes:
{
TSBaseEntity = <4797118c 50068f2f f544d9a9 4884720b 55ec7e4d 0d4c8f4e 1ee44be3 b06d2edc>;
TSBuyer = <91e837d1 3f348913 eff634d6 6fb9b3a6 747e2390 fbdc4ae6 32cc56d6 7582d4a8>;
...
}
destination hashes: {
TSBaseEntity = <4797118c 50068f2f f544d9a9 4884720b 55ec7e4d 0d4c8f4e 1ee44be3 b06d2edc>;
TSBuyer = <e316a857 8919c4be eef15387 5c67a21b 67d32919 99ead438 1ff93c05 2e065fcc>;
...
}
CoreData: annotation: (migration) checking mapping model at path file://localhost/Users/xandrews/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/0A84951E-21FC-47C0-A1B7-F880ACB672C4/Dev.app/Migrate_0_5_24To_0_5_27.cdm
source hashes:
{(
<4797118c 50068f2f f544d9a9 4884720b 55ec7e4d 0d4c8f4e 1ee44be3 b06d2edc>,
<91e837d1 3f348913 eff634d6 6fb9b3a6 747e2390 fbdc4ae6 32cc56d6 7582d4a8>,
...
)}
destination hashes: {(
<4797118c 50068f2f f544d9a9 4884720b 55ec7e4d 0d4c8f4e 1ee44be3 b06d2edc>,
<e316a857 8919c4be eef15387 5c67a21b 67d32919 99ead438 1ff93c05 2e065fcc>,
...
)}
CoreData: annotation: (migration) no suitable mapping model found
CoreData: annotation: (migration) inferring a mapping model between data models with
source hashes: ...
所以我們不能在Xcode 4.6.2中使用遷移工具,因爲它會生成錯誤的文件? – 2013-07-04 08:06:47
我不知道這是否是解決方案,但它肯定是一種解決方案。使用由Xcode 5 DP4生成的文件爲我工作。 – 2013-08-01 17:24:49
對於Xcode 4,請嘗試[此答案](http://stackoverflow.com/a/9428260/1402846)。 – Pang 2013-09-22 07:49:34