I'm using EF Core.
My Customer
entity has properties Address1
, Address2
, and AddressFull
.
Depending on which system sends me the data, I may receive Address1
and Address2
, or I may receive AddressFull
.
So I need:
- EITHER
Address1
andAddress2
required, andAddressFull
not-required - OR
Address1
andAddress2
not-required, andAddressFull
required
So I have:
entityTypeBuilder.Property(p => p.Address1).IsRequired(false);
entityTypeBuilder.Property(p => p.Address2).IsRequired(false);
entityTypeBuilder.Property(p => p.AddressFull).IsRequired(false);
But this config does not properly map to my domain, and I want to enforce the logic. Is that possible in EF Core?