Old local persistent store to new CloudKit store- lightweight migration

I have a new model which syncs to cloudkit. I'have to migrate my old core data store which is local to the new model which will store in cloudkit. I'm not sure how to perform this migration. The container is initialised correctly and the Mapping Model is mapping my entities and attributes correctly. There are no errors.

Yet, I do not see my old records upon fetching. I found this lines of code here...

NSDictionary *optionsDictionary = [[NSDictionary alloc] initWithObjectsAndKeys:
    [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption,
    [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
    <#Ubiquitous content name#>, NSPersistentStoreUbiquitousContentNameKey, nil];

However, I'm not sure where to add it. Since, I had created a new project folder with core data + CloudKit (and imported the old model), this is the method i got in AppDelegate which initialises the store...

- (NSPersistentCloudKitContainer *)persistentContainer {

    // The persistent container for the application. This implementation creates and returns a container, having loaded the store for the application to it.

    @synchronized (self) {

        if (_persistentContainer == nil) {

            _persistentContainer = [[NSPersistentCloudKitContainer alloc] initWithName:@"Expenses"];

            [_persistentContainer loadPersistentStoresWithCompletionHandler:^(NSPersistentStoreDescription *storeDescription, NSError *error) {

                if (error != nil) {
                    NSLog(@"Unresolved error %@, %@", error, error.userInfo);
                    abort();
                }            
 else
#ifdef DEBUG
                    NSLog(@"Store successfully initialized");
#endif
            }];
        }
    }
    return _persistentContainer;
}

Please help, Thanks.

To summarise my question, when and where do I pass the options dictionary?

Any help is appreciated.

I used the storeDescription's properties to check if the store automatically migrates and if the mapping model is inferred and I got a Yes. So think the issue is something else.

I realised I hadn't selected a container for the iCloud store. Since default container is not shown I selected one of the two containers I had. Now the app prints a huge log and there are no errors. Yet, retuned array is empty. Should I also select 'used with cloudkit' for the old store? If i do It gives me error saying many attributes should be optional. I am assuming this will mean changing the old store from what it is in the live app. I'll test it and get back.

I made the change. Deleted the current app. Downloaded the old app from app store. added data. ran the new app. no errors reported. fetched array is still empty.

Old local persistent store to new CloudKit store- lightweight migration
 
 
Q