我想在ApplicationUser和另一个模型之间建立一对多的关系。问题是我的模型类在另一个类库中,并且我无法将其引用到启动项目中,因为它创建了循环依赖项。有什么想法我可以做什么?
public class Publication
{
public int ID { get; set; }
public string Type { get; set; }
public string ApplicationUserID { get; set; }
//Here is the problem
public virtual ApplicationUser ApplicationUser { get; set; }
}
[抱歉,很难从您发布的信息中理解您的问题。请使用上下文详细说明问题,以便我们可以为您提供帮助。
如果一对多表示one Publication to many ApplicationUser
,则应将AppliationUser
修改为ICollection<ApplicationUser>
。
public class Publication
{
public int ID { get; set; }
public string Type { get; set; }
public string ApplicationUserID { get; set; }
public virtual ICollection<ApplicationUser> ApplicationUsers { get; set; }= new List<ApplicationUser>();
}