title: Trying to understand Repository Pattern with EF6
body: <p>I am currently implementing EF6 to replace the ADO connection that currently exists.</p>
  
  <p>I have read articles on why I should/shouldn't use the Repository pattern.</p>
  
  <p>However I'm still not sure how to correctly call the repository pattern.</p>
  
  <p>My project is layered as:
  <li>Presentation
  <li>Business Layer
  <li>Business Objects
  <li>Data Access Layer
  <li>Web Services</p>
  
  <p>In the DAL I add my EF6 connection to my DB.
  I created a IRepository and Repository classes.</p>
  
  <p>Should the Business Layer be the one to call the Repository class?
  If so I'm missing the connection here on how to call it.</p>
  
  <p>Repository class:</p>
  
  <pre><code>public class MyRepository&lt;T&gt; : IRepository&lt;T&gt; where T : class 
  {
      protected DbSet&lt;T&gt; DbSet;
      protected DbContext _context;
  
      public MyRepository(DbContext dataContext)
      {
          _context = dataContext;
          DbSet = dataContext.Set&lt;T&gt;();
      }
  
      #region IRepository
  
      public int Save()
      {
          return _context.SaveChanges();
      }
  
      public void Insert(T entity)
      {
          DbSet.Add(entity);
      }
  
      public void Delete(T entity)
      {
          DbSet.Remove(entity);
      }
  
      public IQueryable&lt;T&gt; SearchFor(System.Linq.Expressions.Expression&lt;Func&lt;T, bool&gt;&gt; predicate)
      {
          return DbSet.Where(predicate);
      }
  
      public IQueryable&lt;T&gt; GetAll()
      {
          return DbSet;
      }
  
      public T GetById(int id)
      {
          return DbSet.Find(id);
      } 
      #endregion
  }
  </code></pre>
  
  <p>My goal is to have MyRepository handle the 6 or so tables that I added in EF.</p>
  
  <p>Where I am missing is how to implement this class in my business access layer.</p>
  
  <p>I get the error
  'MyEFConn' is a 'type' but is used like a 'variable'</p>
  
  <p>My attempt at implementing it is:</p>
  
  <pre><code>MyRepository&lt;"table from EF"&gt; users = new MyRepository&lt;"table from EF"&gt;(MyEFConn);
  </code></pre>
  
  <p>Which MyEFConn is my DbContext class..</p>
  
  <pre><code>public partial class MyEFConn: DbContext
  </code></pre>