title: Error registering generic UnitOfWork<> with IoC
body: <p>I have a generic implementation of UnitOfWork for my DbContexts in my application, that works like below:</p>
  
  <pre><code> public class UnitOfWork&lt;TContext&gt; : IDisposable, IUnitOfWork&lt;TContext&gt;
          where TContext : DbContext
   {
       private readonly TContext _context;
  
       [..UoW default implementations..]
  
       public void Dispose()
       {
          _context.Dispose();
       }
    }
  </code></pre>
  
  <p>And registration...:</p>
  
  <pre><code>public static class SimpleInjectorWebApiInitializer
      {
          /// &lt;summary&gt;Initialize the container and register it as Web API Dependency Resolver.&lt;/summary&gt;
          public static void Initialize()
          {
              var container = new Container();
              container.Options.DefaultScopedLifestyle = new WebApiRequestLifestyle();
  
              InitializeContainer(container);
  
              container.RegisterWebApiControllers(GlobalConfiguration.Configuration);
  
              container.Verify();
  
              GlobalConfiguration.Configuration.DependencyResolver =
                  new SimpleInjectorWebApiDependencyResolver(container);
          }
  
          private static void InitializeContainer(Container container)
          {
  
              // For instance:
              container.Register(typeof(IUnitOfWork&lt;&gt;), typeof(UnitOfWork&lt;&gt;), Lifestyle.Scoped);
              container.RegisterWebApiRequest&lt;IBankRepository, BankRepository&gt;();
              container.RegisterWebApiRequest&lt;IBankService, BankService&gt;();
  
          }
      }
  </code></pre>
  
  <p><strong>When I try to register this type and other services, I'm getting these warnings:</strong></p>
  
  <p>-[Lifestyle Mismatch] <code>UnitOfWork&lt;CustomerContext&gt;</code> (Web API Request) depends on CustomerContext (Transient).</p>
  
  <p>-[Disposable Transient Component] CustomerContext is registered as transient, but implements IDisposable.</p>
  
  <p>My application architecture uses a default WebAPI implementation:</p>
  
  <pre><code>[RoutePrefix("customer/banks")]
      public class BankController : ApiController
      {
          private readonly IBankService _bankService;
  
          public BankController(IBankService bankService)
          {
              _bankService = bankService;
          }
  
          [Route]
          public IEnumerable&lt;BancoModel&gt; Get()
          {
              var result = _bankService.GetBanks();
              [...mappings and return...]            
          }
      }
  </code></pre>
  
  <p>I've already tried to supress these warnings:</p>
  
  <pre><code>Registration registration = container.GetRegistration(typeof(IUnitOfWork&lt;&gt;)).Registration;
              registration.SuppressDiagnosticWarning(DiagnosticType.DisposableTransientComponent, "Dispose called by application code");
  </code></pre>
  
  <p>..but I receive an InvalidOperationException.</p>
  
  <p>Any ideas on how to register this?</p>