web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Resolve Duplicate Key Row in Object 'dbo.ModelElement' with Unique Index 'I_ModelElement_Id1Id2'

(0) ShareShare
ReportReport
Posted on by 395

When attempting to install a hotfix in R2 for some cleanup jobs I am met with the following error message:

AxUtil call returned errors:
Cannot insert duplicate key row in object 'dbo.ModelElement' with unique index 'I_ModelElement_Id1Id2'. The duplicate key value is (42, 102689, 60003).
The statement has been terminated.
Error updating model database: Microsoft.Dynamics.Setup.AxSetupException: AxUtil call returned errors:Cannot insert duplicate key row in object 'dbo.ModelElement' with unique index 'I_ModelElement_Id1Id2'. The duplicate key value is (42, 102689, 60003).
The statement has been terminated.

I have found the element in SQL that this is complaining about and it is a custom made table, but I am not sure how to correct the issue. Usually when installing models AX will automatically assign new element IDs, but clearly in this case it can't for some reason. I have not found any help articles that detail what to really do in this case.

Thanks.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    If it is just a test environment you could try to remove the customization that you have id conflict with, apply the hotfix and then import back the changes. If it is a table/field, you also have to make sure you sort out the id conflict in the SQLDictionary table, and the number sequence reference too.

  • Travis Bagley Profile Picture
    395 on at

    Thanks for the reply. I had considered doing this, but then what happens when I need to move this to a production box? The modification is already live and doing as you suggest I believe would cause loss of data with a model store move? Isn't there some other method to make the installer use a new ID? Isn't this the same idea as the conflict push override parameters when using AXUtil to install models?

  • Vilmos Kintera Profile Picture
    46,149 on at

    I am unsure how your specific hotfix is packaged. In most of the cases it is just a model file, which does not include AOS-generated identifiers (OriginId, Element Id), could contain Legacy Id when it is from a previous AX version. However that does not interfere with the modelstore's unique element ids.

    In case I face ID conflicts on tables and fields during a release of a modelstore to Production I just run a custom job to sort out the table/field ID in the SQLDictionary and SystemSequences tables, and any other tables that are referring the table's tableId in question, before doing a Data Dictionary synchronization. Also because the table's indexes contain it's ID in the database, that should be recreated in case the ID changes for the existing table within SQL.

  • Travis Bagley Profile Picture
    395 on at

    I am using the provided hotifx installer from LCS. I have never had this happen before which leads me to believe there must be a deeper issue.

  • Travis Bagley Profile Picture
    395 on at

    I guess what I would like to understand is if a model file doesn't have AOS generated identifiers then how can it conflict with elements already in place? I attempted to find and remove the table/field(s) that are causing the issue, but somehow I can't find them in AX. The AX IDs don't match and if I lookup the parentElement I don't find anything.

  • Verified answer
    Vilmos Kintera Profile Picture
    46,149 on at

    Do you have any orphaned elements in your _model database?

    The following scripts should give you any elements that does not have a parent based on ParentHandle, or RootHandle. Or any which has an element but no data.

    SELECT * FROM [dbo].[MODELELEMENT] AS Element
    WHERE NOT (EXISTS (
    	SELECT 'x' FROM [dbo].[ModelElementData] AS Data
    		WHERE Element.ElementHandle = Data.ElementHandle
    	))
    ORDER BY Element.Name ASC
    
    SELECT * FROM [dbo].[MODELELEMENT] AS Element
    WHERE 
    	(
    		Element.ParentHandle <> 0 AND 
    		NOT (EXISTS (
    		SELECT 'x' FROM [dbo].[ModelElement] AS Parent
    			WHERE Parent.ElementHandle = Element.ParentHandle
    		))
    	)
    	OR (
    		Element.RootHandle <> 0 AND 
    		NOT (EXISTS (
    		SELECT 'x' FROM [dbo].[ModelElement] AS Parent2
    			WHERE Parent2.ElementHandle = Element.RootHandle
    		))
    	)
    ORDER BY Element.Name ASC


  • Travis Bagley Profile Picture
    395 on at

    Yes. I ended up figuring out that there were a few orphaned elements. I do not understand how this could have happened, but never the less it seems like this is an issue that occurred without anyone knowing. I wondering if it could have been caused by someone deleting a table or moving it between layers and AX crashed and didn't clean up the garbage? Either way after finding the orphans I deleted them and the hotfix installed with no issues.

  • Sathish_Chinnappan Profile Picture
    1,318 on at

    Hi,

    Im getting the same error while installing Patch.

    Update model details metadata not available.

    Following files will be imported as part of this update: D:\AX_GST_Update\Microsoft Dynamics India GST AX 2012 R2 GA release\AX2012R2KB4019353\DynamicsAX2012R2-KB4019353-App\Models\dynamicsax2012r2-kb4019353-foundation.axmodel, D:\AX_GST_Update\Microsoft Dynamics India GST AX 2012 R2 GA release\AX2012R2KB4019353\DynamicsAX2012R2-KB4019353-App\Models\dynamicsax2012r2-kb4019353-syplabels.axmodel.

    Using AxUtil to connect to database "MSDynamicsAXCRM_model" on server "WIN-TST2254".

    Calling AxUtil to import model file "D:\AX_GST_Update\Microsoft Dynamics India GST AX 2012 R2 GA release\AX2012R2KB4019353\DynamicsAX2012R2-KB4019353-App\Models\dynamicsax2012r2-kb4019353-foundation.axmodel".

    Calling AxUtil to import model file "D:\AX_GST_Update\Microsoft Dynamics India GST AX 2012 R2 GA release\AX2012R2KB4019353\DynamicsAX2012R2-KB4019353-App\Models\dynamicsax2012r2-kb4019353-syplabels.axmodel".

    AxUtil call is complete.

    AxUtil call returned errors:

    Cannot insert duplicate key row in object 'dbo.ModelElement' with unique index 'I_ModelElement_Id1Id2'. The duplicate key value is (42, 102947, 60001).

    The statement has been terminated.

    Error updating model database: Microsoft.Dynamics.Setup.AxSetupException: AxUtil call returned errors:Cannot insert duplicate key row in object 'dbo.ModelElement' with unique index 'I_ModelElement_Id1Id2'. The duplicate key value is (42, 102947, 60001).

    The statement has been terminated.

  • Sathish_Chinnappan Profile Picture
    1,318 on at

    I run the SQL query given by vilmos and i got 12 records. I have deleted those records and tried installing the patch again. Still Same error.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans