title: Entity Framework Polymorphic associations
body: <p>I'm going to use Entity Framework soon for a Booking System ( made from scratch ).</p>
  <p>I have been doing a few Prototypes, trying to figure out what I want to do before the project is started (I'm still discussing requirements etc. with the client).</p>
  <p>Consider this case:</p>
  <p>I have a Booking, and a booking can have associated Ressources, that can be booked, but these ressource can be different, and have different Fields etc.</p>
  <p><img src="https://i.stack.imgur.com/utsiS.png" alt="ER Diagram of the Relationship" /></p>
  <p>I have never really used EF before, so I don't know how I can achieve this kind of Polymorphism, that I am use to in other projects (where we have been using raw SQL).</p>
  <p>The C# Model would look like this:</p>
  <pre><code>public class Booking
  {
      public int BookingID { get; set; }
      public DateTime StartTime { get; set; }
      public DateTime EndTime { get; set; }
      public IRessource Ressources { get; set; }
      ...
  }
  
  public interface IRessource
  {
      public int RessourceTypeId { get; set; }
  }
  
  public class Room : IRessource
  {
      public int RoomID { get; set; }
      public int RessourceTypeId { get; set; }
      ...
  }
  
  public class Car : IRessource
  {
      public int CarID { get; set; }
      public int RessourceTypeId { get; set; }
      ...
  }
  </code></pre>
  <p>Is this achievable, and if yes, then how?
  How would the querying even look?</p>