KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
weird one. (Probably not weird, at all) I have 3 objects, Employee, Rota and Department. public class Employee { public int Id { get; set; } public String Name { get; set; } public virtual Department Department { get; set; } } internal class EmployeeMapping : EntityTypeConfiguration<Employee> { public EmployeeMapping() { HasKey(a => a.Id); Property(a => a.Id).HasColumnName("UserId"); HasRequired<Department>(a => a.Department).WithOptional().Map(a => a.MapKey("DepartmentId")); } } public class Department { public int Id { get; set; } public String Name { get; set; } } internal class DepartmentMapping : EntityTypeConfiguration<Department> { public DepartmentMapping() { HasKey(a => a.Id); Property(a => a.Id).HasColumnName("DepartmentId"); } } public class Rota { public int Id { get; set; } public virtual Employee Employee { get; set; } public virtual Department Department { get; set; } } internal class RotaMapping : EntityTypeConfiguration<Rota> { public RotaMapping() { HasKey(a => a.Id); Property(a => a.Id).HasColumnName("RotaId"); HasOptional<Employee>(a => a.Employee).WithOptionalDependent().Map(a => a.MapKey("EmployeeId")); HasOptional<Department>(a => a.Department).WithOptionalDependent().Map(a => a.MapKey("DepartmentId")); } } Not complicated, at all really. Rota can have an Employee and/or a Department assigned to it, all of this is configured using Fluent. All of my associations are correct (the schema is perfect), however I have a weird oddity. When I do a myContext.Departments.FirstOrDefault() and have a look at the SQL Generated, there is a LEFT OUTER JOIN on Employee & Rota. Why is this there? I don't want it to do this. Maybe my Fluent mappings are in
Tags (comma-separated)
Save Edits
Cancel