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.
Solution
Prerequisites: Access to the DNN database (from site interface or directly via SSMS)
Diagnosis
-
Determine the DNN feature that is failing and check the related tables.
For example: If the issue is related to pages, check the
Tabs
andTabVersions
tables in the database. If the issues are related to modules on pages, check the TabModules and TabModuleSettings tables. -
Use the
If the issue is occurring while accessing modules on pages, run the following command:SELECT
command to find the duplicate entries while filtering with the related feature id.
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. -
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.
Resolution
-
Create a backup of the database.
-
Restore the backup in a test environment.
-
Remove the duplicate data that you have identified above in the last step of Diagnosis.
Example:DELETE FROM TabModules WHERE TabModuleID = 123
or,DELETE FROM TabVersions WHERE TabVersionId = 123
-
Access the DNN logs in the SiteRoot/Portals/_default/Logs folder to see if there are any same key errors from before.
-
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.