/// <summary>
/// The greoup.
/// </summary>
public class Group
{
#region Public Properties
/// <summary>
/// Gets or sets the group id.
/// </summary>
[Key]
public int GroupId { get; set; }
/// <summary>
/// Gets or sets the parent group id.
/// </summary>
public int ParentGroupId { get; set; }
/// <summary>
/// Gets or sets the active.
/// </summary>
public int Active { get; set; }
/// <summary>
/// Gets or sets the description.
/// </summary>
public string Description { get; set; }
/// <summary>
/// Gets or sets the group guid.
/// </summary>
public Guid GroupGuid { get; set; }
/// <summary>
/// Gets or sets the order weight.
/// </summary>
public int OrderWeight { get; set; }
/// <summary>
/// Gets or sets the parent group.
/// </summary>
[ForeignKey("ParentGroupId")]
public virtual Group ParentGroup { get; set; }
/// <summary>
/// Gets or sets the groups.
/// </summary>
public virtual ICollection<Group> Groups { get; set; }
#endregion
}
我怎樣才能允許退出外鍵。因爲當我嘗試添加Group時,ParentGroupId = 0。我得到異常
無法確定依賴操作的有效順序。由於外鍵約束,模型要求或商店生成的值,可能會存在依存關係。
你是什麼意思的「退出外鍵」? GroupId是標識列嗎?你能顯示引發異常的代碼嗎? –