Base solution for your next web application
Open Closed

Update statement conflicts with FOREIGN KEY SAME TABLE ? #199


User avatar
0
wangwei22 created

Hi, When learning Module Zero's sample, I got the follow error when try to login:

{"UPDATE 语句与 FOREIGN KEY SAME TABLE 约束"FK_dbo.AbpUsers_dbo.AbpUsers_LastModifierUserId"冲突。该冲突发生于数据库"QrCodeCMSMZ",表"dbo.AbpUsers", column 'Id'。\r\n语句已终止。"}

The meaning in English: UPDATE statement conflicted with TABLE FOREIGN KEY constraint '<foreign key constraint name>'. The conflict occurred in database '<database name>', table '<table name>'. The statement has been terminated.

My User class:

public class User : AbpUser<Tenant, User>
{
/// <summary>
/// </summary>
public virtual int UserType { get; set; }

/// <summary>
/// </summary>
public virtual int? CompanyId { get; set; }
[ForeignKey("CompanyId")]
public virtual Company Company { get; set; }

public override string ToString()
{
    return string.Format("[User {0}] {1}", Id, UserName);
}
}

And I did not modify the controller and action。

Why this happened, and how to fix it?

Thanks.


2 Answer(s)
  • User Avatar
    0
    wangwei22 created

    I'v found the reason, my cookie is polluted, everything goes well after I clear the cookies.

  • User Avatar
    0
    farb created

    <cite>wangwei22: </cite> I'v found the reason, my cookie is polluted, everything goes well after I clear the cookies.

    Thanks for your useful answer!