Looking for PowerObjects? Don’t worry, you’re in the right place! We’ve been part of HCL for several years, and we’ve now taken the final step in our acquisition journey: moving our website to the HCL domain. Nothing else is changing – we are still fanatically focused on Microsoft Business Applications!

PowerObjects Blog 

for Microsoft Business Applications


Duplicate Key Row Error during Upgrade to CRM 2013

Post Author: Joe D365 |

Greetings fellow CRMers!

Nothing spoils the excitement of upgrading your CRM 2011 organization to CRM 2013 like a lousy error. If you've experienced this key row error, we'll tell you how to keep it from ruining your day.

This particular error occurs while the upgrade wizard is processing the upgrade. It may not be flagged as a concern during the validation portion, but the upgrade may fail and the error within the log will state:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Data.SqlClient.SqlException: Cannot insert duplicate key row in object 'MetadataSchema.AttributePicklistValue' with unique index 'ndx_AttributePicklistValue'. The duplicate key value is (c5157c5f-9375-446c-8e8b-1659c0c5d54c, 5, 0, , Jan 1 1900 12:00AM).

Reason for the Error

This error is due to a few "extra" user CAL license types in the caltype field on the systemuser entity. Specifically the extra CAL types are "Employee Self Service" and "Device Employee Self Service." These CAL types do not show up on the License Type Option Set on the user form, but you can see them if you look at the caltype field on the systemuser entity. This option set is locked so you cannot remove these options in the CRM field configuration.

Duplicate Key Row Error while upgrading to CRM 2013

In SQL, you can verify these values by running this query against your organization database:

select * from metadataschema.AttributePicklistValue where Optionsetid = 'c5157c5f-9375-446c-8e8b-1659c0c5d54c'

The results will show more than the standard five license types.

Resolving the Error

NOTE: This blog describes removing values from the CRM organization database using SQL server to solve a very specific issue. As always, make sure you have a good database backup before following these steps.

To resolve the issue, take the following steps.

  1. Take a backup of your database.
  2. Run the following query:

    delete from MetadataSchema.AttributePicklistValue where Value > '4' and Optionsetid = 'c5157c5f-9375-446c-8e8b-1659c0c5d54c'

This will get rid of the extra license types that were preventing you from upgrading, and it should be clear sailing afterward.

If you are facing an issue upgrading your CRM organization to CRM 2013, we'd love to help you through it! Contact us for support, or, if you'd like to sit back and relax, we'll do it all for you.

Happy CRM'ing!

Joe CRM
By Joe D365
Joe D365 is a Microsoft Dynamics 365 superhero who runs on pure Dynamics adrenaline. As the face of PowerObjects, Joe D365’s mission is to reveal innovative ways to use Dynamics 365 and bring the application to more businesses and organizations around the world.

PowerObjects Recommends