0
我有一个类(Employee)在我的DBContext中,我想通过导航属性与另一个类(Office)加入。 Office类是来自外部源的东西。这是可以轻松完成的事吗?实体框架 - 导航属性外部源
public class Employee
{
[Key]
public int EmployeeId { get; set; }
public string OfficeCode { get; set; }
public virtual Office Office { get; set; }
}
public class Office
{
public string OfficeCode { get; set; }
public string Name { get; set; }
}
public class MyContext : DbContext
{
public virtual IDbSet<Employee> Employees { get; set; }
public MyContext() : base("name=constring")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
}
}
办公室可以收集:
Office GetOfficeByOcd(string ocd);
这太糟糕了。谢谢你的澄清。 – DrivenTooFar