我有那些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是的,我確實 –