An Item with the Same Key Has Already Been Added

Overview 

 If there are duplicate values in the database, you may encounter the following error message in the DNN Logs located in the Portals/_default/Logs folder and the browser console logs by pressing F12.:

An item with the same key has already been added.

This article describes the troubleshooting process and resolution for this issue.

 

Prerequisites

  • Access to the DNN database (from site interface or directly via SSMS)

 

Diagnosis

  1. Determine the DNN feature that is failing and check the related tables.

    For example: If the issue is related to pages, check the Tabs and TabVersions tables in the database. If the issues are related to modules on pages, check the TabModules and TabModuleDetails tables.

  2. Use the SELECT command to find the duplicate entries while filtering with the related feature id.

    If the issue is occurring while accessing modules on pages, run the following command:
    SELECT * FROM TabModules WHERE TabID = '<page ID>'
    To find out at any instances of duplicated IDs.
    SELECT TabID, COUNT(*) FROM Tabs GROUP BY TabID HAVING COUNT(*) > 1
    Where <page ID> is the ID of the page where the issue is occurring.
    This might simplify the process of identifying the offending record for the end-user.
  3. From the returned results, note down the data discrepancies and duplicates and have a clear understanding of what needs to be fixed to resolve the error. 

 

Solution

  1. Create a backup of the database.

  2. Restore the backup in a test environment.

  3. Remove the duplicate data that you have identified while troubleshooting.

  4. Access the DNN logs in the SiteRoot/Portals/_default/Logs folder to see if there are any same key errors from before.

  5. If the test is successful, perform the same steps on the actual database.

 

Testing

  • Repeat the steps which initially caused the error that you've performed in the Diagnosis to confirm the issue has been successfully resolved.

 

Comments

0 comments

Please sign in to leave a comment.