"An item with the same key already exists" error?

"An item with the same key already exists" error?

SELECT e.n.value(‘(@ID)[1]’, ‘varchar(max)’) as ID,
e.n.value(‘declare namespace dm=”http://schemas/.microsoft.com/sqlserver/2004/10/semanticmodeling”; (dm:Name/text())[1]’, ‘varchar(max)’) as Entity,
e.n.value(‘declare namespace dm=”http://schemas/.microsoft.com/sqlserver/2004/10/semanticmodeling”; (dm:Table/@Name)[1]’, ‘varchar(max)’) as Source
FROM ( SELECT cast (content as xml) as Content FROM SECUREDITEM WHERE path = ‘/DataModels/SystemModel’ ) m
CROSS APPLY m.[Content].nodes(‘declare namespace dm=”http://schemas/.microsoft.com/sqlserver/2004/10/semanticmodeling”;
/dm:SemanticModel/dm:Entities/dm:EntityFolder/dm:Entities/dm:Entity’) AS e(n)
ORDER BY SOURCE

SELECT e.n.value(‘(@name)[1]’, ‘varchar(max)’) as Name,
e.n.value(‘declare namespace msprop=”urn:schemas-microsoft-com:xml-msprop”; (@msprop:DbTableName)[1]’, ‘varchar(max)’) as DbTable
FROM ( SELECT cast (content as xml) as Content FROM SECUREDITEM WHERE path = ‘/DataModels/SystemModel’ ) m
cross APPLY m.[Content].nodes(‘declare namespace dm=”http://schemas/.microsoft.com/sqlserver/2004/10/semanticmodeling”;declare namespace dsv=”http://schemas/.microsoft.com/analysisservices/2003/engine”;
/dm:SemanticModel/dsv:DataSourceView/dsv:Schema/xs:schema/xs:element/xs:complexType/xs:choice/xs:element’) AS e(n)
order by DbTable

This error is generated when something is duplicated within the system model, usually a table (the duplicated item can appear in various ways). Sometimes it’s an attribute that is found in the setup manager, other cases it’s a table that’s part of an old schema, that sometimes cannot be seen through the DSV. If this problem is not solved it will stop the user’s application and all other users from either updating security or regenerating the system model.

This query lists out all of the source tables for entities that exist within the system model, so if there are duplicates you can see them right next to each other.

undefined

The user needs to delete the duplicate and their problem should be solved.

undefined