title: Can I abstract Entity Framework away from my Entities?
body: <p>I have a <code>Foo</code> entity in Entity Framework. But I'm making it inherit from <code>IFoo</code> so that my business logic only knows <code>IFoo</code> - thus abstracting Entity Framework away.</p>
  
  <p>The problem is that <code>Foo</code> has a collection of <code>Bar</code> entities. And this collection is of type <code>EntityCollection&lt;Bar&gt;</code> . </p>
  
  <p>If I put this collection in <code>IFoo</code> as it is, I make <code>IFoo</code> dependent on Entity Framework. So I thought of putting it as <code>ICollection&lt;IBar&gt;</code>, but this doesn't compile (naturally).</p>
  
  <p>The only solution I can think of is to go to the concrete <code>Foo</code> implementation generated by the Entity Framework designer and change the collection from <code>EntityCollection&lt;Bar&gt;</code> to <code>ICollection&lt;IBar&gt;</code> there. But I dread the thought of the implications this will have on Entity Framework "behind the scenes".</p>
  
  <p>Is there any way for me to define <code>IFoo</code> and <code>IBar</code> independently of Entity Framework while still maintaining <code>Foo</code> and <code>Bar</code> as EF Entities that implement them? Do <code>IFoo</code> and <code>IBar</code> even make sense, if I cannot achieve this independence that I aim for?</p>