Error when upgrading to AX 2012 Feature Pack: The UPDATE statement conflicted with the FOREIGN KEY constraint “FK_ModelElementData_HasModelId_LayerId”

When performing a Minor-version upgrade by installing Microsoft Dynamics AX 2012 Feature pack on top of AX 2012 RTM installation with one or more of the following industry solutions installed (like Service Industries, Process Industries, Public Sector and/or beta AX-Retail), you may get errors like:

SQL Error description: {Microsoft][SQL Server Native Client 10.0][SQL Server]The UPDATE statement conflicted with the FOREIGN KEY constraint “FK_ModelElementData_HasModelId_LayerId”. The conflict occurred in database “AXDB”, table”dbo.Model”.

Here’s a screenshot of what you may see:



After some research we identified the problem was in the installation specific ID assignment stored procedure. In this stored procedure AX ID gets re-assigned/enumerated if an ID is already taken by existing model element. In some cases there can be ID conflicts in the ModelElementMerge table, which is the temporary host of model element data, for example when multiple models get imported as one batch, or a model has customization that has an AXID which also being used by another model element in same model (our case).

This issue is now resolved kernel hotfix build version 6.0.1108.226 and above and is included in recently released Cumulative Update 3 (CU-3). Installing the kernel hotfix on its own DOES NOT resolve the issue once you already have the problem. We recommend to redo the upgrade with a restored backup and than install the kernel hotfix and slipstream the hotfix in your AX 2012 Feature Pack installation files.


(1) Following the instructions of the AX 2012 Minor version upgrade article first  install the hotfix kernel 6.0.1108.226 and above instead of the kernel version 6.0.947.862 of the DynamicsAX2012-KB2650968 hotfix as mentioned at point 4 in the article.

(2) Unpack the hotfix kernel  6.0.1108.226 downloaded from the above link (or CU-3) and copy the extracted files to a separate folder in the Updates folder in your AX 2012 Feature Pack installation files. And use that folder from point 4 onwards.


–author: Jago van der Most