How do I enforce an either-or relationship between model properties, using EF Core?
问题 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 and Address2 required, and AddressFull not-required OR Address1 and Address2 not-required, and AddressFull required So I have: entityTypeBuilder.Property(p => p.Address1).IsRequired(false); entityTypeBuilder.Property(p => p.Address2).IsRequired(false);