title: Entity Framework code first ctp 5 using an IDbSet in RepositoryBase class
body: <p>I want to find out if it makes sense to use the Entity Framework code first ctp 5 IDbSet in a Repository base class .</p>
  
  <p>I am using the Repository Pattern(and would like to follow the persistence ignorance method) for my implementations and I would like to use fake data for testing(by using a fake in memory IDBset implementation).</p>
  
  <p>I feel that adding a dependency to the 
  System.Data.Entity.IDbSet would tie my implementation of the repository base class to the IDBset and if there are any future changes to it that might break the code. What is the best way of implementaing a repository base class without the Idbset dependency?</p>
  
  <p>I am following this post :<a href="http://romiller.com/2010/09/07/ef-ctp4-tips-tricks-testing-with-fake-dbcontext/" rel="nofollow">EF CTP4 Tips &amp; Tricks: Testing With Fake DbContext</a> to implement fakes.</p>
  
  <pre><code>//_dbset impliments the IDBset
  
  //Database inherits from DbContext
  
      protected RepositoryBase(UnitOfWork  unitOfWork)
      {
          _unitOfWork = unitOfWork;
          _dbset = _unitOfWork.Database.Set&lt;T&gt;();
      }       
  
      public virtual void Add(T entity)
      {
          _dbset.Add(entity);
      }
  
      public virtual void Delete(T entity)
      {
          _dbset.Remove(entity);
      }
  
      public virtual T GetById(long id)
      {
          return _dbset.Find(id);
      }
  
      public virtual IEnumerable&lt;T&gt; All()
      {
          return _dbset.ToList();
      }
  </code></pre>