Try our conversational search powered by Generative AI!

SQL exception occurred when deleting a block that was being used as inlineBlock of ContentArea

Found in

EPiServer.CMS.Core 12.12.1

Fixed in

EPiServer.CMS.Core 12.14.0

(Or a related package)

Created

Feb 20, 2023

Updated

Apr 18, 2023

Area

CMS Core

State

Closed, Fixed and tested


Description

Fixed an issue where a SQL exception occurred when deleting a block that was being used as inlineBlock of ContentArea.

Steps to reproduce:

1. Create a block type (either typed on a .NET model or through Admin view) with a property (such as a string property called Heading).

2. Create a page instance of a type that contains a content area and assign an instance of an inline block using above block type, such as through the following code.

var page = _contentRepository.GetDefault<StandardPage>(ContentReference.StartPage);{{        }}
  page.Name = "ToBeDeleted";{{        }}
  page.MainContentArea = new ContentArea();
{{  page.MainContentArea.Items.Add(new ContentAreaItem { }}
    InlineBlock = _blockPropertyFactory.Create<InlineBlock>(b => b.Heading = "someting") });
    _contentRepository.Save(page, SaveAction.Publish, AccessLevel.NoAccess);

3. If you created the block type from .NET code, remove the block type from the .NET code.

4. Go to Admin view and try to delete the block.