title: Condition one of two properties to be different of null Entity Framework Code First
body: <p>I am using EF6 Code First. Suppose the following scenario. We have this class:</p>
  
  <pre><code>class Foo
  {
      public int Id { get; set; }
      public A AProperty { get; set; }
      public B BProperty { get; set; }
  }
  </code></pre>
  
  <p>Is there a way, by using either Data Annotations or Entity Framework Fluent Api and without redesigning the whole model, to ensure that any Foo entity must have either at least one property different of null but not both?</p>
  
  <p>It is something like what is answered in this <a href="https://stackoverflow.com/questions/25138805/only-allow-one-of-two-columns-to-be-set">question</a> but with EF.</p>