Same error while upgrading Microsoft Dynamics CRM
I recently upgrade from Microsoft Dynamics 365 (CRM 2016 On-Premise) to Dynamics 365 Server, v9.0
I had the same error-message with a different "duplicate key value".
The root-cause of the problem was that I had "duplicate values" in the CRM-Database-Objects.
The following Query lists such duplicates:
SELECT TABLE_NAME, COLUMN_NAME, COUNT(*) Count
FROM INFORMATION_SCHEMA.COLUMNS GROUP BY TABLE_NAME, COLUMN_NAME HAVING COUNT(*) > 1
Of course the duplicates where in my own database-objects (views) that I had created in my own schemas.
Renaming my own objects/views or the columns in the views to make sure the above query doesn't list any results solved my problem.
After the changes in my own objects I was able to do the Upgrade