AX 2012 [Error] : Violation of PRIMARY KEY constraint 'PK_ModelElementData_ElementHandle'. Cannot insert duplicate key in object 'dbo.ModelElementData'.
Hi Developers,
Today, we will talk about below error in AX 2012 R2/R3 or D365 FO. When we upgrade or apply an hot-fix into AX environment, we might face some challenges, suppose you are installing hot-fix in your environment and face an error, open your log file and check for error in the end of the file, one is below:
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 (822606, 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 (822606, 1).
The statement has been terminated.
at Microsoft.Dynamics.Setup.Misc.ValidateAxUtilStatus(AxUtilContext context)
at Microsoft.Dynamics.Setup.DatabaseSqlModel.DatabaseSqlModelInstanceCommon.ImportModelFiles(IEnumerable`1 filenames, IEnumerable`1 modelsToReplace)
at Microsoft.Dynamics.Setup.DatabaseSqlModel.DatabaseSqlModelInstanceUpdate.Execute()
An error occurred during setup of Model Database.
Solution:
In this error, we can see that there is a duplicate key associate with table ModelElementData. So we need to check and delete it according.
1) Check if there is any data available with the associate duplicate id.
[Use Your_Model_DB]
select * from ModelElementData where ElementHandle = 822606;
2) And, if you find any data is available in this table associate with duplicate key, delete it.
[Use Your_Model_DB]
delete from ModelElementData where ElementHandle = 822606;
3) Now, re-run your hot-fix. It should be successful this time.
Author:
Chirag Gupta
Microsoft Dynamics 365 AX Technical Consultant at IBM Bangalore
Date:
5-Sep-2019
Happy Learning !!
Today, we will talk about below error in AX 2012 R2/R3 or D365 FO. When we upgrade or apply an hot-fix into AX environment, we might face some challenges, suppose you are installing hot-fix in your environment and face an error, open your log file and check for error in the end of the file, one is below:
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 (822606, 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 (822606, 1).
The statement has been terminated.
at Microsoft.Dynamics.Setup.Misc.ValidateAxUtilStatus(AxUtilContext context)
at Microsoft.Dynamics.Setup.DatabaseSqlModel.DatabaseSqlModelInstanceCommon.ImportModelFiles(IEnumerable`1 filenames, IEnumerable`1 modelsToReplace)
at Microsoft.Dynamics.Setup.DatabaseSqlModel.DatabaseSqlModelInstanceUpdate.Execute()
An error occurred during setup of Model Database.
Solution:
In this error, we can see that there is a duplicate key associate with table ModelElementData. So we need to check and delete it according.
1) Check if there is any data available with the associate duplicate id.
[Use Your_Model_DB]
select * from ModelElementData where ElementHandle = 822606;
2) And, if you find any data is available in this table associate with duplicate key, delete it.
[Use Your_Model_DB]
delete from ModelElementData where ElementHandle = 822606;
3) Now, re-run your hot-fix. It should be successful this time.
Author:
Chirag Gupta
Microsoft Dynamics 365 AX Technical Consultant at IBM Bangalore
Date:
5-Sep-2019
Happy Learning !!
Comments
Post a Comment