Core Data lightweight migration: change relationship from To-One to To-Many










1















I recently made a few changes to my Core Data model file and I'm trying to perform a lightweight migration. I've already worked with lightweight migrations before so I know I did all the setup correctly.



My only problem is that I changed the type of a relationship: it used to be To-One and now it's To-Many. According to Apple's documentation, lightweight migrations should work just fine in this case, but when I run the code and the system starts migrating the data, there is a crash.



I noticed in the stack trace the following method is causing the crash:



3 CoreData 0x008df2d1 -[_NSSQLEntityMigrationDescription 
_populateSQLValuesForDestinationToOne:fromSourceToOne:] + 145


So for some reason the method being called is trying to migrate the relationship as if it still was a To-One relationship.



Why is the mapping model being inferred incorrectly, and how can I fix it?



Thanks!



EDIT



This is the error message that I get:



*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '*** setObjectForKey: object cannot be nil (key: Z8CUSCONNECTION)'


cusConnection is the name of the relationship that I changed from To-One to To-Many.



Also, here is the stack trace:



0 CoreFoundation 0x01588746 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x01211a97 objc_exception_throw + 44
2 CoreFoundation 0x01479c9c -[__NSDictionaryM setObject:forKey:] + 940
3 CoreData 0x009182d1 -[_NSSQLEntityMigrationDescription _populateSQLValuesForDestinationToOne:fromSourceToOne:] + 145
4 CoreData 0x00918d30 -[_NSSQLEntityMigrationDescription _populateSQLValuesForVirtualToOnesWithMigrationContext:] + 1648
5 CoreData 0x00918202 -[_NSSQLEntityMigrationDescription _generateSQLValueMappingsWithMigrationContext:] + 962
6 CoreData 0x0091998b -[_NSSQLEntityMigrationDescription sqlValueForColumnName:migrationContext:] + 59
7 CoreData 0x00923cf1 -[_NSSQLTableMigrationDescription createInsertStatementForEntityMigration:migrationContext:] + 689
8 CoreData 0x00922d07 -[_NSSQLTableMigrationDescription appendStatementsToPerformMigration:migrationContext:] + 1143
9 CoreData 0x0091d024 -[_NSSQLiteStoreMigrator createEntityMigrationStatements] + 900
10 CoreData 0x0091b088 -[_NSSQLiteStoreMigrator performMigration:] + 104
11 CoreData 0x0092753a -[NSSQLiteInPlaceMigrationManager migrateStoreFromURL:type:options:withMappingModel:toDestinationURL:destinationType:destinationOptions:error:] + 1962
12 CoreData 0x008b9104 -[NSMigrationManager migrateStoreFromURL:type:options:withMappingModel:toDestinationURL:destinationType:destinationOptions:error:] + 692
13 CoreData 0x00908605 -[NSStoreMigrationPolicy(InternalMethods) migrateStoreAtURL:toURL:storeType:options:withManager:error:] + 341
14 CoreData 0x009074b5 -[NSStoreMigrationPolicy migrateStoreAtURL:withManager:metadata:options:error:] + 117
15 CoreData 0x00909380 -[NSStoreMigrationPolicy(InternalMethods) _gatherDataAndPerformMigration:] + 3136
16 CoreData 0x008c2c76 __91-[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:]_block_invoke + 5270
17 CoreData 0x008d12ff gutsOfBlockToNSPersistentStoreCoordinatorPerform + 191
18 libdispatch.dylib 0x03593bef _dispatch_client_callout + 14
19 libdispatch.dylib 0x03576b0d _dispatch_barrier_sync_f_invoke + 144
20 libdispatch.dylib 0x0357623f dispatch_barrier_sync_f + 105
21 CoreData 0x008c03f7 _perform + 183
22 CoreData 0x007b272c -[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:] + 236
23 Nimbus II 0x00117fd2 -[AppDelegate persistentStoreCoordinator] + 674
24 Nimbus II 0x002c79b6 +[UserInformationParser saveData:] + 374
25 Nimbus II 0x001c2f2e __47-[SynchronizationController synchronizeData]_block_invoke + 366
26 libdispatch.dylib 0x035715ea _dispatch_call_block_and_release + 15
27 libdispatch.dylib 0x03593bef _dispatch_client_callout + 14
28 libdispatch.dylib 0x0357b1ef _dispatch_root_queue_drain + 1092
29 libdispatch.dylib 0x0357cb70 _dispatch_worker_thread3 + 115
30 libsystem_pthread.dylib 0x038d843e _pthread_wqthread + 1050
31 libsystem_pthread.dylib 0x038d5f72 start_wqthread + 34









share|improve this question
























  • You should post the entire crash instead of just one line out of it. The error being displayed in the debug console as well as the full stack will help to diagnose the issue.

    – Marcus S. Zarra
    Jan 12 '16 at 23:53











  • @marcus-s-zarra There it is :-)

    – Diego
    Jan 13 '16 at 23:26












  • Is the mapping model generated by Core Data?

    – Willeke
    Jan 14 '16 at 2:37











  • @Willeke yep. Automatic lightweight migration

    – Diego
    Jan 14 '16 at 2:43











  • @Diego I just ran into the exact same problem (on iOS 9). Did you figure out a solution in the end? Or did you just end up using a custom (non-lightweight) migration?

    – Hendrik
    Mar 8 '16 at 3:00















1















I recently made a few changes to my Core Data model file and I'm trying to perform a lightweight migration. I've already worked with lightweight migrations before so I know I did all the setup correctly.



My only problem is that I changed the type of a relationship: it used to be To-One and now it's To-Many. According to Apple's documentation, lightweight migrations should work just fine in this case, but when I run the code and the system starts migrating the data, there is a crash.



I noticed in the stack trace the following method is causing the crash:



3 CoreData 0x008df2d1 -[_NSSQLEntityMigrationDescription 
_populateSQLValuesForDestinationToOne:fromSourceToOne:] + 145


So for some reason the method being called is trying to migrate the relationship as if it still was a To-One relationship.



Why is the mapping model being inferred incorrectly, and how can I fix it?



Thanks!



EDIT



This is the error message that I get:



*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '*** setObjectForKey: object cannot be nil (key: Z8CUSCONNECTION)'


cusConnection is the name of the relationship that I changed from To-One to To-Many.



Also, here is the stack trace:



0 CoreFoundation 0x01588746 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x01211a97 objc_exception_throw + 44
2 CoreFoundation 0x01479c9c -[__NSDictionaryM setObject:forKey:] + 940
3 CoreData 0x009182d1 -[_NSSQLEntityMigrationDescription _populateSQLValuesForDestinationToOne:fromSourceToOne:] + 145
4 CoreData 0x00918d30 -[_NSSQLEntityMigrationDescription _populateSQLValuesForVirtualToOnesWithMigrationContext:] + 1648
5 CoreData 0x00918202 -[_NSSQLEntityMigrationDescription _generateSQLValueMappingsWithMigrationContext:] + 962
6 CoreData 0x0091998b -[_NSSQLEntityMigrationDescription sqlValueForColumnName:migrationContext:] + 59
7 CoreData 0x00923cf1 -[_NSSQLTableMigrationDescription createInsertStatementForEntityMigration:migrationContext:] + 689
8 CoreData 0x00922d07 -[_NSSQLTableMigrationDescription appendStatementsToPerformMigration:migrationContext:] + 1143
9 CoreData 0x0091d024 -[_NSSQLiteStoreMigrator createEntityMigrationStatements] + 900
10 CoreData 0x0091b088 -[_NSSQLiteStoreMigrator performMigration:] + 104
11 CoreData 0x0092753a -[NSSQLiteInPlaceMigrationManager migrateStoreFromURL:type:options:withMappingModel:toDestinationURL:destinationType:destinationOptions:error:] + 1962
12 CoreData 0x008b9104 -[NSMigrationManager migrateStoreFromURL:type:options:withMappingModel:toDestinationURL:destinationType:destinationOptions:error:] + 692
13 CoreData 0x00908605 -[NSStoreMigrationPolicy(InternalMethods) migrateStoreAtURL:toURL:storeType:options:withManager:error:] + 341
14 CoreData 0x009074b5 -[NSStoreMigrationPolicy migrateStoreAtURL:withManager:metadata:options:error:] + 117
15 CoreData 0x00909380 -[NSStoreMigrationPolicy(InternalMethods) _gatherDataAndPerformMigration:] + 3136
16 CoreData 0x008c2c76 __91-[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:]_block_invoke + 5270
17 CoreData 0x008d12ff gutsOfBlockToNSPersistentStoreCoordinatorPerform + 191
18 libdispatch.dylib 0x03593bef _dispatch_client_callout + 14
19 libdispatch.dylib 0x03576b0d _dispatch_barrier_sync_f_invoke + 144
20 libdispatch.dylib 0x0357623f dispatch_barrier_sync_f + 105
21 CoreData 0x008c03f7 _perform + 183
22 CoreData 0x007b272c -[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:] + 236
23 Nimbus II 0x00117fd2 -[AppDelegate persistentStoreCoordinator] + 674
24 Nimbus II 0x002c79b6 +[UserInformationParser saveData:] + 374
25 Nimbus II 0x001c2f2e __47-[SynchronizationController synchronizeData]_block_invoke + 366
26 libdispatch.dylib 0x035715ea _dispatch_call_block_and_release + 15
27 libdispatch.dylib 0x03593bef _dispatch_client_callout + 14
28 libdispatch.dylib 0x0357b1ef _dispatch_root_queue_drain + 1092
29 libdispatch.dylib 0x0357cb70 _dispatch_worker_thread3 + 115
30 libsystem_pthread.dylib 0x038d843e _pthread_wqthread + 1050
31 libsystem_pthread.dylib 0x038d5f72 start_wqthread + 34









share|improve this question
























  • You should post the entire crash instead of just one line out of it. The error being displayed in the debug console as well as the full stack will help to diagnose the issue.

    – Marcus S. Zarra
    Jan 12 '16 at 23:53











  • @marcus-s-zarra There it is :-)

    – Diego
    Jan 13 '16 at 23:26












  • Is the mapping model generated by Core Data?

    – Willeke
    Jan 14 '16 at 2:37











  • @Willeke yep. Automatic lightweight migration

    – Diego
    Jan 14 '16 at 2:43











  • @Diego I just ran into the exact same problem (on iOS 9). Did you figure out a solution in the end? Or did you just end up using a custom (non-lightweight) migration?

    – Hendrik
    Mar 8 '16 at 3:00













1












1








1








I recently made a few changes to my Core Data model file and I'm trying to perform a lightweight migration. I've already worked with lightweight migrations before so I know I did all the setup correctly.



My only problem is that I changed the type of a relationship: it used to be To-One and now it's To-Many. According to Apple's documentation, lightweight migrations should work just fine in this case, but when I run the code and the system starts migrating the data, there is a crash.



I noticed in the stack trace the following method is causing the crash:



3 CoreData 0x008df2d1 -[_NSSQLEntityMigrationDescription 
_populateSQLValuesForDestinationToOne:fromSourceToOne:] + 145


So for some reason the method being called is trying to migrate the relationship as if it still was a To-One relationship.



Why is the mapping model being inferred incorrectly, and how can I fix it?



Thanks!



EDIT



This is the error message that I get:



*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '*** setObjectForKey: object cannot be nil (key: Z8CUSCONNECTION)'


cusConnection is the name of the relationship that I changed from To-One to To-Many.



Also, here is the stack trace:



0 CoreFoundation 0x01588746 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x01211a97 objc_exception_throw + 44
2 CoreFoundation 0x01479c9c -[__NSDictionaryM setObject:forKey:] + 940
3 CoreData 0x009182d1 -[_NSSQLEntityMigrationDescription _populateSQLValuesForDestinationToOne:fromSourceToOne:] + 145
4 CoreData 0x00918d30 -[_NSSQLEntityMigrationDescription _populateSQLValuesForVirtualToOnesWithMigrationContext:] + 1648
5 CoreData 0x00918202 -[_NSSQLEntityMigrationDescription _generateSQLValueMappingsWithMigrationContext:] + 962
6 CoreData 0x0091998b -[_NSSQLEntityMigrationDescription sqlValueForColumnName:migrationContext:] + 59
7 CoreData 0x00923cf1 -[_NSSQLTableMigrationDescription createInsertStatementForEntityMigration:migrationContext:] + 689
8 CoreData 0x00922d07 -[_NSSQLTableMigrationDescription appendStatementsToPerformMigration:migrationContext:] + 1143
9 CoreData 0x0091d024 -[_NSSQLiteStoreMigrator createEntityMigrationStatements] + 900
10 CoreData 0x0091b088 -[_NSSQLiteStoreMigrator performMigration:] + 104
11 CoreData 0x0092753a -[NSSQLiteInPlaceMigrationManager migrateStoreFromURL:type:options:withMappingModel:toDestinationURL:destinationType:destinationOptions:error:] + 1962
12 CoreData 0x008b9104 -[NSMigrationManager migrateStoreFromURL:type:options:withMappingModel:toDestinationURL:destinationType:destinationOptions:error:] + 692
13 CoreData 0x00908605 -[NSStoreMigrationPolicy(InternalMethods) migrateStoreAtURL:toURL:storeType:options:withManager:error:] + 341
14 CoreData 0x009074b5 -[NSStoreMigrationPolicy migrateStoreAtURL:withManager:metadata:options:error:] + 117
15 CoreData 0x00909380 -[NSStoreMigrationPolicy(InternalMethods) _gatherDataAndPerformMigration:] + 3136
16 CoreData 0x008c2c76 __91-[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:]_block_invoke + 5270
17 CoreData 0x008d12ff gutsOfBlockToNSPersistentStoreCoordinatorPerform + 191
18 libdispatch.dylib 0x03593bef _dispatch_client_callout + 14
19 libdispatch.dylib 0x03576b0d _dispatch_barrier_sync_f_invoke + 144
20 libdispatch.dylib 0x0357623f dispatch_barrier_sync_f + 105
21 CoreData 0x008c03f7 _perform + 183
22 CoreData 0x007b272c -[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:] + 236
23 Nimbus II 0x00117fd2 -[AppDelegate persistentStoreCoordinator] + 674
24 Nimbus II 0x002c79b6 +[UserInformationParser saveData:] + 374
25 Nimbus II 0x001c2f2e __47-[SynchronizationController synchronizeData]_block_invoke + 366
26 libdispatch.dylib 0x035715ea _dispatch_call_block_and_release + 15
27 libdispatch.dylib 0x03593bef _dispatch_client_callout + 14
28 libdispatch.dylib 0x0357b1ef _dispatch_root_queue_drain + 1092
29 libdispatch.dylib 0x0357cb70 _dispatch_worker_thread3 + 115
30 libsystem_pthread.dylib 0x038d843e _pthread_wqthread + 1050
31 libsystem_pthread.dylib 0x038d5f72 start_wqthread + 34









share|improve this question
















I recently made a few changes to my Core Data model file and I'm trying to perform a lightweight migration. I've already worked with lightweight migrations before so I know I did all the setup correctly.



My only problem is that I changed the type of a relationship: it used to be To-One and now it's To-Many. According to Apple's documentation, lightweight migrations should work just fine in this case, but when I run the code and the system starts migrating the data, there is a crash.



I noticed in the stack trace the following method is causing the crash:



3 CoreData 0x008df2d1 -[_NSSQLEntityMigrationDescription 
_populateSQLValuesForDestinationToOne:fromSourceToOne:] + 145


So for some reason the method being called is trying to migrate the relationship as if it still was a To-One relationship.



Why is the mapping model being inferred incorrectly, and how can I fix it?



Thanks!



EDIT



This is the error message that I get:



*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '*** setObjectForKey: object cannot be nil (key: Z8CUSCONNECTION)'


cusConnection is the name of the relationship that I changed from To-One to To-Many.



Also, here is the stack trace:



0 CoreFoundation 0x01588746 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x01211a97 objc_exception_throw + 44
2 CoreFoundation 0x01479c9c -[__NSDictionaryM setObject:forKey:] + 940
3 CoreData 0x009182d1 -[_NSSQLEntityMigrationDescription _populateSQLValuesForDestinationToOne:fromSourceToOne:] + 145
4 CoreData 0x00918d30 -[_NSSQLEntityMigrationDescription _populateSQLValuesForVirtualToOnesWithMigrationContext:] + 1648
5 CoreData 0x00918202 -[_NSSQLEntityMigrationDescription _generateSQLValueMappingsWithMigrationContext:] + 962
6 CoreData 0x0091998b -[_NSSQLEntityMigrationDescription sqlValueForColumnName:migrationContext:] + 59
7 CoreData 0x00923cf1 -[_NSSQLTableMigrationDescription createInsertStatementForEntityMigration:migrationContext:] + 689
8 CoreData 0x00922d07 -[_NSSQLTableMigrationDescription appendStatementsToPerformMigration:migrationContext:] + 1143
9 CoreData 0x0091d024 -[_NSSQLiteStoreMigrator createEntityMigrationStatements] + 900
10 CoreData 0x0091b088 -[_NSSQLiteStoreMigrator performMigration:] + 104
11 CoreData 0x0092753a -[NSSQLiteInPlaceMigrationManager migrateStoreFromURL:type:options:withMappingModel:toDestinationURL:destinationType:destinationOptions:error:] + 1962
12 CoreData 0x008b9104 -[NSMigrationManager migrateStoreFromURL:type:options:withMappingModel:toDestinationURL:destinationType:destinationOptions:error:] + 692
13 CoreData 0x00908605 -[NSStoreMigrationPolicy(InternalMethods) migrateStoreAtURL:toURL:storeType:options:withManager:error:] + 341
14 CoreData 0x009074b5 -[NSStoreMigrationPolicy migrateStoreAtURL:withManager:metadata:options:error:] + 117
15 CoreData 0x00909380 -[NSStoreMigrationPolicy(InternalMethods) _gatherDataAndPerformMigration:] + 3136
16 CoreData 0x008c2c76 __91-[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:]_block_invoke + 5270
17 CoreData 0x008d12ff gutsOfBlockToNSPersistentStoreCoordinatorPerform + 191
18 libdispatch.dylib 0x03593bef _dispatch_client_callout + 14
19 libdispatch.dylib 0x03576b0d _dispatch_barrier_sync_f_invoke + 144
20 libdispatch.dylib 0x0357623f dispatch_barrier_sync_f + 105
21 CoreData 0x008c03f7 _perform + 183
22 CoreData 0x007b272c -[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:] + 236
23 Nimbus II 0x00117fd2 -[AppDelegate persistentStoreCoordinator] + 674
24 Nimbus II 0x002c79b6 +[UserInformationParser saveData:] + 374
25 Nimbus II 0x001c2f2e __47-[SynchronizationController synchronizeData]_block_invoke + 366
26 libdispatch.dylib 0x035715ea _dispatch_call_block_and_release + 15
27 libdispatch.dylib 0x03593bef _dispatch_client_callout + 14
28 libdispatch.dylib 0x0357b1ef _dispatch_root_queue_drain + 1092
29 libdispatch.dylib 0x0357cb70 _dispatch_worker_thread3 + 115
30 libsystem_pthread.dylib 0x038d843e _pthread_wqthread + 1050
31 libsystem_pthread.dylib 0x038d5f72 start_wqthread + 34






ios xcode core-data database-migration






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 13 '16 at 23:26







Diego

















asked Jan 12 '16 at 16:48









DiegoDiego

298212




298212












  • You should post the entire crash instead of just one line out of it. The error being displayed in the debug console as well as the full stack will help to diagnose the issue.

    – Marcus S. Zarra
    Jan 12 '16 at 23:53











  • @marcus-s-zarra There it is :-)

    – Diego
    Jan 13 '16 at 23:26












  • Is the mapping model generated by Core Data?

    – Willeke
    Jan 14 '16 at 2:37











  • @Willeke yep. Automatic lightweight migration

    – Diego
    Jan 14 '16 at 2:43











  • @Diego I just ran into the exact same problem (on iOS 9). Did you figure out a solution in the end? Or did you just end up using a custom (non-lightweight) migration?

    – Hendrik
    Mar 8 '16 at 3:00

















  • You should post the entire crash instead of just one line out of it. The error being displayed in the debug console as well as the full stack will help to diagnose the issue.

    – Marcus S. Zarra
    Jan 12 '16 at 23:53











  • @marcus-s-zarra There it is :-)

    – Diego
    Jan 13 '16 at 23:26












  • Is the mapping model generated by Core Data?

    – Willeke
    Jan 14 '16 at 2:37











  • @Willeke yep. Automatic lightweight migration

    – Diego
    Jan 14 '16 at 2:43











  • @Diego I just ran into the exact same problem (on iOS 9). Did you figure out a solution in the end? Or did you just end up using a custom (non-lightweight) migration?

    – Hendrik
    Mar 8 '16 at 3:00
















You should post the entire crash instead of just one line out of it. The error being displayed in the debug console as well as the full stack will help to diagnose the issue.

– Marcus S. Zarra
Jan 12 '16 at 23:53





You should post the entire crash instead of just one line out of it. The error being displayed in the debug console as well as the full stack will help to diagnose the issue.

– Marcus S. Zarra
Jan 12 '16 at 23:53













@marcus-s-zarra There it is :-)

– Diego
Jan 13 '16 at 23:26






@marcus-s-zarra There it is :-)

– Diego
Jan 13 '16 at 23:26














Is the mapping model generated by Core Data?

– Willeke
Jan 14 '16 at 2:37





Is the mapping model generated by Core Data?

– Willeke
Jan 14 '16 at 2:37













@Willeke yep. Automatic lightweight migration

– Diego
Jan 14 '16 at 2:43





@Willeke yep. Automatic lightweight migration

– Diego
Jan 14 '16 at 2:43













@Diego I just ran into the exact same problem (on iOS 9). Did you figure out a solution in the end? Or did you just end up using a custom (non-lightweight) migration?

– Hendrik
Mar 8 '16 at 3:00





@Diego I just ran into the exact same problem (on iOS 9). Did you figure out a solution in the end? Or did you just end up using a custom (non-lightweight) migration?

– Hendrik
Mar 8 '16 at 3:00












1 Answer
1






active

oldest

votes


















0














Lightweight (or Automatic) migration does support changing relationship from To-one to To-many.



Several steps:



  • Create new model (xcdatamodel)

  • Reset the type if you've created a class (from a class type to NSSet since its one-to-many relationship)

  • Change the relationship for the entity in the new model you just created (from one-to-one to one-to-many)

  • In the Data Model Inspector of the relationship, under the Versioning, set the Renaming ID with the last relationship name (without s).

The lightweight migrator will create mapping based on it.



It works as same as renaming the entity, etc.






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f34749301%2fcore-data-lightweight-migration-change-relationship-from-to-one-to-to-many%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Lightweight (or Automatic) migration does support changing relationship from To-one to To-many.



    Several steps:



    • Create new model (xcdatamodel)

    • Reset the type if you've created a class (from a class type to NSSet since its one-to-many relationship)

    • Change the relationship for the entity in the new model you just created (from one-to-one to one-to-many)

    • In the Data Model Inspector of the relationship, under the Versioning, set the Renaming ID with the last relationship name (without s).

    The lightweight migrator will create mapping based on it.



    It works as same as renaming the entity, etc.






    share|improve this answer



























      0














      Lightweight (or Automatic) migration does support changing relationship from To-one to To-many.



      Several steps:



      • Create new model (xcdatamodel)

      • Reset the type if you've created a class (from a class type to NSSet since its one-to-many relationship)

      • Change the relationship for the entity in the new model you just created (from one-to-one to one-to-many)

      • In the Data Model Inspector of the relationship, under the Versioning, set the Renaming ID with the last relationship name (without s).

      The lightweight migrator will create mapping based on it.



      It works as same as renaming the entity, etc.






      share|improve this answer

























        0












        0








        0







        Lightweight (or Automatic) migration does support changing relationship from To-one to To-many.



        Several steps:



        • Create new model (xcdatamodel)

        • Reset the type if you've created a class (from a class type to NSSet since its one-to-many relationship)

        • Change the relationship for the entity in the new model you just created (from one-to-one to one-to-many)

        • In the Data Model Inspector of the relationship, under the Versioning, set the Renaming ID with the last relationship name (without s).

        The lightweight migrator will create mapping based on it.



        It works as same as renaming the entity, etc.






        share|improve this answer













        Lightweight (or Automatic) migration does support changing relationship from To-one to To-many.



        Several steps:



        • Create new model (xcdatamodel)

        • Reset the type if you've created a class (from a class type to NSSet since its one-to-many relationship)

        • Change the relationship for the entity in the new model you just created (from one-to-one to one-to-many)

        • In the Data Model Inspector of the relationship, under the Versioning, set the Renaming ID with the last relationship name (without s).

        The lightweight migrator will create mapping based on it.



        It works as same as renaming the entity, etc.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 13 '18 at 21:00









        John YangJohn Yang

        12




        12



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f34749301%2fcore-data-lightweight-migration-change-relationship-from-to-one-to-to-many%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            What does pagestruct do in Eviews?

            Dutch intervention in Lombok and Karangasem

            Channel Islands