I'm trying to specify that I already have a discriminator on the entity, but am not sure how to represent it here.
The discriminator between them is whether or not a column is null. Obviously the case where it is null I can just put that explicitly, but what do I do for the case where its not?
protected override void OnModelCreating(ModelBuilder modelBuilder) {
modelBuilder.Entity<Schedule>()
.HasDiscriminator<Guid?>("ManagerId")
.HasValue<EmployeeSchedule>(null)
.HasValue<ManagerSchedule>(/* What goes here? */);
}
Solved it by putting the property bool IsManagerSchedule
on Schedule
, and then using .HasValue<ManagerSchedule>(true).HasValue<EmployeeSchedule>(false);
.
Try removing the manual configuration and then:
public class EmployeeSchedule {
// properties of all employees...
}
public class ManagerSchedule {
public TYPE PropertyName {get; set;} // discriminator property
}