title: StructureMap 2.6.1, an IRepository<T> and a EFRepository<T,TContext>
body: <p>So I thought I'd be slick and try this.  I need to pass around a context without newing it up every time AND be able to define the mappings (Entity framework) -- in order to do this I need to inherit then override the DbContext class.  I'd like to keep it plugable with any context I toss in so that's what led me to this.  I got a IRepository interface that takes a  (entity) with your usual suspects in it, and an implementation of it with a dependency on IContextFactory ...</p>
  
  <pre><code>public interface IContextFactory&lt;T&gt; where T : DbContext
  {
      T Context { get; }
  }
  </code></pre>
  
  <p>And on my "EFRepository"</p>
  
  <pre><code>public class EFRepository&lt;T, TContext&gt; : IRepository&lt;T&gt; where T : class
          where TContext : DbContext
  {
  
      public EFRepository(IContextFactory&lt;TContext&gt; contextFactory)
      {
      }
  }
  </code></pre>
  
  <p>In my mapping, I did one of these jobs ...</p>
  
  <pre><code>        x.For(typeof(IContextFactory&lt;&gt;)).Use(typeof(ContextFactory&lt;&gt;));
          x.For(typeof(IRepository&lt;&gt;)).Use(typeof(EFRepository&lt;,&gt;));
  </code></pre>
  
  <p>Ok cool.  In my unit tests, I try it this way...</p>
  
  <pre><code>        var repository = ObjectFactory.GetInstance&lt;EFRepository&lt;Currency, EFContext&gt;&gt;();
          var repository2 = ObjectFactory.GetInstance&lt;IRepository&lt;Currency&gt;&gt;();
  </code></pre>
  
  <p>First one works, no problem.  2nd one, I get hit with</p>
  
  <p><em>The number of generic arguments provided doesn't equal the arity of the generic type definition.
  Parameter name: instantiation</em></p>
  
  <p>I'm guessing it's because I'm not telling structuremap which generic to pass on to IRepository since I'm passing 2?  How do I do that?  ...can I do that?</p>