我有那些2种型号如何查询对一个多对多的关系,与实体框架6
public class BranchEmployees
{
public int ID { get; set; }
[Required, Column(Order = 0), Key]
public string ApplicationUserID { get; set; }
[Required, Column(Order = 1), Key]
public int BranchID { get; set; }
public virtual ICollection<ApplicationUser> ApplicationUser { get; set; }
public virtual ICollection<Branch> Branch { get; set; }
}
public class Branch
{
public int ID { get; set; }
public string BranchName { get; set; }
[Required]
public string ApplicationUserID { get; set; }
public ApplicationUser User { get; set; }
public virtual ICollection<BranchEmployees> BranchEmployees { get; set; }
}
public class ApplicationUser
{
//rest of the code
}
UPDATE 我把一切都建立了,但我想要的是让我其雇员查询ID在分支雇员表中 ,我首先使用实体框架代码与MVC 5,我该怎么做?
您是否使用代码优先来创建数据库? –
@MartinShishkov是的,我确实 –