【发布时间】:2016-10-16 05:09:22
【问题描述】:
我有一个以 EntityBase 作为父类的用户实体。 父类如下所示:
public class EntityBase
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public Guid Id { get; set; }
public bool? IsPublic { get; set; }
public bool? IsActive { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
public DateTime? DeletedAt { get; set; }
public virtual User CreatedBy { get; set; }
public Guid? CreatedById { get; set; }
public virtual User UpdatedBy { get; set; }
public Guid? UpdatedById { get; set; }
public virtual User DeletedBy { get; set; }
public Guid? DeletedById { get; set; }
}
用户类:
public class User : EntityBase
{
public string Username { get; set; }
public string Email { get; set; }
public string Password { get; set; }
public string Token { get; set; }
public DateTime LastLogin { get; set; }
public DateTime LastAction { get; set; }
public bool IsLocked { get; set; }
public bool IsAdmin { get; set; }
public virtual ICollection<Cocktail> Cocktails { get; set; }
public virtual ICollection<Drink> DrinkVotes { get; set; }
public virtual ICollection<Cocktail> CocktailVotes { get; set; }
}
现在我遇到了自引用的问题,因为存在循环依赖,我该如何解决这个问题?
【问题讨论】:
标签: c# entity-framework entity code-first