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