title: How to include optional relations in C# using Code First Entity Framework
body: <p>Having the DB below I would like to retrieve all bricks in C# and include the Workshops on those BrickBacks that has any.</p>
  
  <p>I managed to retrieve all the Bricks and include the BrickBacks by simply doing</p>
  
  <pre><code>context.Bricks.Include(b=&gt;b.Back).ToList()
  </code></pre>
  
  <p>But in this case BrickBack is an abstract class which its subclass <strong><em>may</em></strong> contain a Workshop but this is not always the case.</p>
  
  <p>Unfortunately I can't just do</p>
  
  <pre><code>context.Bricks.Include(b=&gt;b.Back).Include(b=&gt;b.Back.Workshop).ToList()
  </code></pre>
  
  <p>How can this be done?</p>
  
  <p><img src="https://i.stack.imgur.com/AyaSd.png" alt="DB Diagram"></p>