title: How-to inject the Entity Framework DbContext into the ConfigurationBasedRepository of SharpRepository
body: <p>I really would like to use <a href="https://github.com/SharpRepository/SharpRepository" rel="noreferrer">SharpRepository</a> together with <a href="http://www.ninject.org" rel="noreferrer">Ninject</a>, but I do not understand how to configure Ninject to share the Entity Framework DbContext between the repositories.</p>
  
  <p>I am using Entity Framework version 5 and Ninject version 3.</p>
  
  <p>Currently I am using <code>Ef5Repository</code> in my source code, but I want to replace it with <code>ConfigurationBasedRepository</code>. But I cannot figure out how to pass (or inject) the EF <code>DbContext</code> to the repositories.</p>
  
  <p><strong>Example (current state):</strong></p>
  
  <pre><code>using SharpRepository.Repository;
  
  public interface IProductRepository : IRepository&lt;Product&gt;
  {
  }
  
  using SharpRepository.Ef5Repository;
  using System.Data.Entity;
  
  // TODO Tightly coupled to Ef5Repository.
  public class ProductRepository : Ef5Repository&lt;Product&gt;, IProductRepository
  {
      // TODO The DbContext has to be injected manually.
      public ProductRepository(DbContext context) : base(context)
      {
      }
  
      // [...]
  }
  </code></pre>
  
  <p><strong>Goal:</strong></p>
  
  <pre><code>using SharpRepository.Repository;
  
  public interface IProductRepository : IRepository&lt;Product&gt;
  {
  }
  
  public class ProductRepository : ConfigurationBasedRepository&lt;Product, int&gt;, IProductRepository
  {
      // [...]
  }
  </code></pre>
  
  <p>I've already read the two blog posts <a href="http://fairwaytech.com/2012/12/sharprepository-getting-started" rel="noreferrer">SharpRepository: Getting Started</a> and <a href="http://fairwaytech.com/2013/02/sharprepository-configuration" rel="noreferrer">SharpRepository: Configuration</a>, but they both do not help me, since:</p>
  
  <ol>
  <li>The used DIC is StructureMap, not Ninject.</li>
  <li>The source code examples are incomplete (e.g. usage of not declared variables).</li>
  </ol>
  
  <p>So my question: Can someone provide me with some source code example how-to to achieve the goal described above (sharing one Entity Framework <code>DbContext</code> instance between all repositories extending <code>ConfigurationBasedRepository</code>)?</p>