Wednesday 15 December 2010

The DELETE statement conflicted with the REFERENCE constraint "FK_cmsPropertyData_cmsPropertyType" - Umbraco

The DELETE statement conflicted with the REFERENCE constraint "FK_cmsPropertyData_cmsPropertyType".



This was incredibly painful!

It occurs when you try to delete a property form a document type.

Here is a quick fix that does not involve manually deleting things....


Open up SQL Management Studio.
Change delete rule for the relationship between cmsPropertyType and cmsPropertyData to "cascade".

DONE!


3 comments:

  1. Hi,

    For those who'd rather run a script I've used the following.

    IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_cmsPropertyData_cmsPropertyType_id]') AND parent_object_id = OBJECT_ID(N'[dbo].[cmsPropertyData]'))
    ALTER TABLE [dbo].[cmsPropertyData] DROP CONSTRAINT [FK_cmsPropertyData_cmsPropertyType_id]
    GO

    ALTER TABLE [dbo].[cmsPropertyData] WITH CHECK ADD CONSTRAINT [FK_cmsPropertyData_cmsPropertyType_id] FOREIGN KEY([propertytypeid])
    REFERENCES [dbo].[cmsPropertyType] ([id])
    ON DELETE CASCADE
    GO

    ALTER TABLE [dbo].[cmsPropertyData] CHECK CONSTRAINT [FK_cmsPropertyData_cmsPropertyType_id]
    GO

    ReplyDelete
  2. Chris is my new best friend...

    ReplyDelete