“An item with the same key has already been added. Key: PageDescription”
“An item with the same key has already been added. Key: PageDescription”
System.ArgumentException:
at System.ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Collections.Generic.Dictionary`2.TryInsert (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Mediachase.MetaDataPlus.Configurator.MetaObjectDB.LoadMetaObjectData (Mediachase.MetaDataPlus, Version=14.15.2.0, Culture=neutral, PublicKeyToken=41d2e7a615ba286c)
at Mediachase.MetaDataPlus.Internal.CatalogMetaObjectRepository.DoLoadFromDb (Mediachase.MetaDataPlus, Version=14.15.2.0, Culture=neutral, PublicKeyToken=41d2e7a615ba286c)
We could use this query to find the content that caused the error:
SELECT TOP(1000) ObjectId, MetaFieldName, COUNT(*) AS Count
FROM [dbo].[CatalogContentProperty]
Where MetaFieldName = 'PageDescription'
GROUP BY ObjectId, MetaFieldName
HAVING COUNT(*) > 1;
=> Found the Content with ID=2
SELECT TOP (1000) * FROM [dbo].[CatalogContentProperty]
Where MetaFieldName = 'PageDescription' and ObjectId= 2
Now the obvious fix is to update that CultureSpecifc = True
UPDATE [dbo].[CatalogContentProperty]
SET CultureSpecific=1
WHERE MetaFieldName = 'PageDescription' and ObjectId= 2 and CultureSpecific=0
GO
Or for more general cases which set the data on all master language (en-US) rows
update p
set CultureSpecific = f.MultiLanguageValue
from [dbo].[ecfVersionProperty] p
inner join MetaField f on p.MetaFieldId = f.MetaFieldId
where LanguageName = 'en-US' AND CultureSpecific is null
For troubleshooting, it would be setting the column to not null, the code that set the data to null would throw an exception and we then know what to do.
ALTER TABLE [ecfVersionProperty] ADD CONSTRAINT [ecfVersionProperty_CultureSpecific]
CHECK (( LanguageName = 'en-US' and CultureSpecific IS NOT NULL) OR (LanguageName != 'en-US'));
Comments
Post a Comment