Charles Charles - 2 months ago 21
C# Question

EF Core HasDiscriminator with nullable discriminator

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) {
.HasValue<ManagerSchedule>(/* What goes here? */);


Solved it by putting the property bool IsManagerSchedule on Schedule, and then using .HasValue<ManagerSchedule>(true).HasValue<EmployeeSchedule>(false);.