System.ArgumentException: An item with the same key has already been added

Why the following error message is displayed: "System.ArgumentException: An item with the same key has already been added."?

When searching for a particular tenant on Orchestrator the following error message is displayed:
System.ArgumentException: An item with the same key has already been added.

This is a backend error message which indicates that duplicate value has been added to a Dictionary, which is not possible in .Net.

The presence of the duplicated value and a Tenant ID having the same license value assigned twice causes this error. 

By the execution of the following query , the duplicate value can be detected:

 

WITH A_CTE (Nume,Lic,TenantId)

as

(

select t.Name as Nume,l.EncryptedLicenseInfo as Lic,l.TenantId

from Tenants t

join Licenses l on l.TenantId = t.Id

) select Nume,count(Nume+Lic) from A_CTE

group by Nume

 

RESOLUTION : Set one of the IDs to "IsDeleted" in SQL, and the error is resolved.