title: How to use Entity Framework context with dependency injection?
body: <p>I'm trying to setup a base Repository class that can use the Entity Framework edmx model context.  The problem I'm having is that I need to find an interface that the EF EDMX object context implements so I can pass to the constructor via dependency injections.  I've got around this before by using a DataFactory that creates it and stores it in the HttpContext but that kills the ability to unit test.  Any help would be appreciated.  Thanks!</p>
  
  <pre><code>public abstract class BaseRepository&lt;T&gt; where T : EntityObject
  {
          private MyDataModelContext _dataContext;
          private ObjectSet&lt;T&gt; dbset;
  
          protected BaseRepository(IObjectContext dataContext)
          {
              _dataContext = dataContext;
              dbset = _dataContext.CreateObjectSet&lt;T&gt;();
          }
  
      .....
  </code></pre>