Content Service - Updating a culture varying property throws SqlException (Cannot insert duplicate key row)
I believe I found a bug on v8, updating a culture varying content through the content service. I already placed this issue. Anyway, I'm posting here, in case someone might help with a workaround or something.
I'm developing a method to create or update some content in my project. I got stuck in a situation where the creation runs fine but the updates always fail with the following SqlException:
Cannot insert duplicate key row in object 'dbo.umbracoPropertyData' with unique index 'IX_umbracoPropertyData_VersionId'. The duplicate key value is (2437, 145, 2, <NULL>). The statement has been terminated.
I narrowed it down to a simple update of a culture varying property, using the content service.
I have a TestVariant culture variant document type, with a culture varying bio property. Here's my code:
var docType = Services.ContentTypeService.Get(TestVariant.ModelTypeAlias);
// create a new content
IContent newContent = new Content("My Content", -1, docType, "en-US");
newContent.SetCultureName("My Content", "pt-PT");
newContent.SetValue("bio", "original", "en-US");
newContent.SetValue("bio", "original", "pt-PT");
Services.ContentService.SaveAndPublish(newContent);
// update a culture varying property
var contentToUpdate = CS.GetById(newContent.Key);
contentToUpdate.SetValue("bio", "updated", "en-US");
contentToUpdate.SetValue("bio", "updated", "pt-PT");
// Following line will throw exception:
// Message: Cannot insert duplicate key row in object 'dbo.umbracoPropertyData' with unique index 'IX_umbracoPropertyData_VersionId'. The duplicate key value is (2414, 51, 2, <NULL>)
Services.ContentService.SaveAndPublish(contentToUpdate);
Content Service - Updating a culture varying property throws SqlException (Cannot insert duplicate key row)
I believe I found a bug on v8, updating a culture varying content through the content service. I already placed this issue. Anyway, I'm posting here, in case someone might help with a workaround or something.
I'm developing a method to create or update some content in my project. I got stuck in a situation where the creation runs fine but the updates always fail with the following SqlException:
I narrowed it down to a simple update of a culture varying property, using the content service.
I have a TestVariant culture variant document type, with a culture varying bio property. Here's my code:
Got it: i should be using the culture ISO code pt and not pt-PT
Thanks, you saved my night ... :-)
is working on a reply...