How to Troubleshoot Issue : The Given Key 'x' Was Not Present in the Dictionary during Orchestrator upgrade?
When trying to perform the upgrade, getting error as : System.Exception: Error:1, Message: An error occurred while migrating Orchestrator data. The given key 'x' was not present in the dictionary.
This issue comes when there is/are any entries which are deleted from database, directly mostly due to dbo.Tenants table.
Identify the tenantsID from database, as these tenant ids are being referenced in various other tables, due to which this issue is being caused.
Note that the following tables still have dependencies
To correct it, create a new tenant to dump the remaining entities and run the following for each table below -
SET TenantId = <NEWTENANTIDVALUE>
WHERE [dbo].[TABLENAME].TenantId NOT IN (
And the following Delete:
WHERE [dbo].[Settings].TenantId NOT IN (
Note : A DB back-up should be performed before doing the above operations .