Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

The INSERT statement conflicted with the FOREIGN KEY constraint

Vote:
 

Hi, colleagues,

The page has two properties of block types (Menu1 and Menu2). The new LinkItemCollection property was implemented for this block types Menu1 and Menu2 with the name Links:

[ContentType(GUID = "42c58e92-58a2-4b9e-b07d-07fe0689be10",

        AvailableInEditMode = false,
        GroupName = CommonContent.GroupNames.Service)]

public class Menu1 : BaseBlock
    {
        [CultureSpecific]
        [Display(Order = 100)]
        public virtual LinkItemCollection Links { get; set;}
    }

[ContentType(GUID = "24b05fcc-02b9-4f4b-add7-b2243a64c0eb",
        AvailableInEditMode = false,
        GroupName = CommonContent.GroupNames.Service)]

public class Menu2 : BaseBlock
    {
        [CultureSpecific]
        [Display(Order = 100)]
        public virtual LinkItemCollection Links { get; set;}
    }

 [ContentType(GUID = "af9de802-30e6-4086-9c9f-b02b5e12835e")]

public class StartPage : BasePage
    {

       [Display(GroupName = CommonContent.TabNames.Menus, Order = 100)]
       public virtual Menu1 TopRightMenu { get; set; }

       [Display(GroupName = CommonContent.TabNames.Footer, Order = 200)]
        public virtual Menu2 SmallFooterInfo { get; set; }

    }

Next error appeared after deploy to production (it appears, if the links were added to the Links field in local blocks on the StartPage):

The INSERT statement conflicted with the FOREIGN KEY constraint "FK_tblWorkContentProperty_tblPropertyDefinition". The conflict occurred in database "Jula", table "dbo.tblPropertyDefinition", column 'pkID'.

The values in the LinkItemCollection fields "Links" desappear after page publishing.

The site was restarted, but it didn't help.

The fields "Links" were renamed and redeployed, but it didn't help.

What should be done to fix the issue?

#86501
May 22, 2014 16:09
Vote:
 

Hi,

I just had the same problem with XhtmlString property.

So I tried to delete the page, empty the trash, and re-create the page. It didn't solve my problem, so I had to create a new XhtmlString property and use that one instead of the old one.

edit: I reverted the old XhtmlString and it works now... strange...

#86510
Edited, May 22, 2014 17:08
Vote:
 

Try to re-generate a guid of your content type, it should fix your problem. 

#86524
May 23, 2014 1:19
Vote:
 

Should I regenerate guid of the StartPage or blocks guids?

#86572
May 23, 2014 20:14
Vote:
 

If I try to revert the Block, the old fields appear again, and the new property from code, which was implemented, vanishes. Is it a cms bug?

I reverted block in admin mode.

#86573
Edited, May 23, 2014 20:22
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.