0

Lets say I have the following EF Core Entity:

public class Day : AuditEntity
{
    public int Id { get; set; }

    public bool IsGame { get; set; }

    public GameDay? GameDay { get; set; }

    public StoryDay? StoryDay { get; set; }
}

Is it possible to make a configuration so that if IsGame is true then GameDay is required otherwise StoryDay is required? I had thought you could maybe solve it in the following manner:

public class DayConfiguration : IEntityTypeConfiguration<Day>
{
    public void Configure(EntityTypeBuilder<Day> builder)
    {
        builder.Property(d => d.GameDay).IsRequired(d => d.IsGame)
    }
}

But obviously IsRequired does not take a function as a parameter.

J.Paravicini
  • 882
  • 12
  • 39

0 Answers0