Violation of PRIMARY KEY constraint ‘PK_ModelElementData_ElementHandle’ error installing some hotfixes on Microsoft Dynamics AX 2012 R2

Greetings all, I want to pass along some information about a scenario where some customers have recently been unable to install some of our hotfix packages for our Microsoft Dynamics AX 2012 R2 release. The scenario only occurs if all of the following conditions are met in the environment where the hotfix is being installed:

  1. The environment is running on application code of Microsoft Dynamics AX 2012 R2 on a release before CU-7
  2. The environment has installed a version of the Data Import Export Framework so that they have a DMF model within the FPK layer.
  3. The hotfix being installed was released AFTER Dynamics AX 2012 R2 CU-7 and before January 2nd, 2014.

If all of those conditions are met, the symptom that partners and customers are seeing is the following error appearing either during the installation of the hotfix or by reviewing the log file after the hotfix fails (the number in the error message may vary):

AxUtil call returned errors:

Violation of PRIMARY KEY constraint ‘PK_ModelElementData_ElementHandle’.Cannot insert duplicate key in object ‘dbo.ModelElementData’. The duplicate key value is (832375, 1).

The statement has been terminated.

Error updating model database:
Microsoft.Dynamics.Setup.AxSetupException: AxUtil call returned errors:Violation of PRIMARY KEY constraint ‘PK_ModelElementData_ElementHandle’. Cannot insert duplicate key in object ‘dbo.ModelElementData’. The duplicate key value is (832375, 1).

The statement has been terminated.

This error was introduced into our hotfixes as an unexpected side effect of merging the Data Import Export Framework code into the SYP layer with our Cumulative Update 7 release, which also moved the DMF labels into the SYP layer. The error we are experiencing is because we were trying to import these same DMF labels again into the SYP layer with the installation of the hotfix.

We have addressed the root cause of the issue so that hotfix packages built now will not contain the DMF labels within the hotfix, and have also released a way for customers and partners who have existing hotfixes that are in this “broken” state to proceed. If you have experienced this issue, you can follow these steps to allow you to install the hotfix package that is currently giving the primary key violation error.

  1. Microsoft has released a special hotfix package that contains only a SYPLabels model file which we will use as a replacement file for your hotfix causing the error.
  2. Go to the following Label File Hotfix link and request a download of the hotfix by filling out the required information.
  3. Submitting the information on the form will generate an automatic email to the email address that was provided on the form which will include another link that is used to download the hotfix itself.
  4. After downloading this special hotfix which should have the name 471807_intl_i386_zip.exe, you can double-click on the executable to extract the contents. This will extract two files – hotfix.txt and DynamicsAX2012R2-KB2923180-SYPLabels.axmodel.
  5. Right-click on the DynamicsAX2012R2-KB2923180-SYPLabels.axmodel file and choose Copy, or select the file in the Windows Explorer and press Ctrl-C to get a copy.
  6. Locate the folder where you extracted the previous hotfix that was causing the error. In the previous hotfix folder, you should see a series of folders that looks similar to the following:


7.  Open the models folder, and you should see contents similar to this:


8. Locate the file that ends with the text syplabels.axmodel and either move it out of that folder or delete it from this models folder.

9. Now paste in the copy of the DynamicsAX2012R2-KB2923180-SYPLabels.axmodel file you took in step 5 above by pressing Ctrl-V in the Models folder or using right-click and choosing Paste. At this point your folder contents should look similar to this.


10. At this point you should be able to go back to the folder where you see the file axupdate.exe and run it just like you normally would to install a hotfix package. Our hotfix installer will then attempt to install this revised version of the SYPLabels.axmodel file and should proceed without the error.


The label file provided will work for any hotfix that was experiencing this error, because it is a cumulative collection of all labels up to the point in time when we fixed the hotfix process. The name of this new SYPLabels.axmodel file does not need to be changed within the models folder, as our hotfix installer will attempt to install each model file within that folder.

If you have issues with this process, or if your auditing requirements for hotfix installation require you to receive a new hotfix package to replace the original hotfix package being installed, please open a support incident and reference this blog article with either the issue you are experiencing or the need for a hotfix package to be recreated.