6
我有兩個類,Group類與User類具有多對多的關係(表示用戶所屬的組),然後該組也與用戶具有一對多的關係類(代表一個組的所有者)。實體框架代碼優先映射
如何映射此?
public class User
{
public int Id { get; set; }
public string Avatar { get; set; }
public string Name { get; set; }
public string Message { get; set; }
public virtual ICollection<Group> OwnedGroups { get; set; }
public virtual ICollection<Group> Groups { get; set; }
}
public class Group
{
public int Id { get; set; }
public DateTime CreateDate { get; set; }
public DateTime ModifyDate { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public bool System { get; set; }
public int ViewPolicy { get; set; }
public int JoinPolicy { get; set; }
public string Avatar { get; set; }
public int Order { get; set; }
public int GroupType { get; set; }
public virtual User Owner { get; set; }
public virtual ICollection<User> Members { get; set; }
}
tks提前!
優秀!!! tks – boossss 2011-04-19 18:49:53
@Ladislav Mrnka可以解釋WillCascadeOnDelete和WithRequired。 PLZ。感謝名單! – 2011-08-11 19:24:41