Error " The Given Key '3' Was Not Present In The Dictionary" While Migrating Orchestrator Data

How to resolve the System.Exception: Error:1 , Message:An error occurred while migrating Orchestrator data. The given key 3 was not present in the dictionary. ?

Issue Description: System.Exception: Error:1 Message:An Error occurred while migrating Orchestrator data. The given key '3' was not present in the dictionary .

Resolution: Perform the below suggested steps
Note: Ensure to take a backup before making any DB changes.

  1. Recreate the missing tenant with id = x using (aprox same) following tsql query,

set identity_insert Tenants on

INSERT INTO [dbo].[Tenants]

VALUES

(x ,'testtenant' ,'testtenant' ,1 ,0 ,null ,null ,null ,null ,getdate() ,1 ,null ,null ,null ,lower(newid())

  1. Re-attempt to install/upgrade Orchestrator using platform installer.

Note: For product versions greater than v.2019, the script recommended in the KB will not work because new columns are added in further versions