title: EfCachingProvider and DbContext
body: <p>I have trying to find the way to use EFCachingProvider from  <a href="http://code.msdn.microsoft.com/EFProviderWrappers-c0b88f32" rel="nofollow">Tracing and Caching Provider Wrappers for Entity Framework</a> with Entity Framework and DbContext. I use EF 4.x DbContext Generator for c# to generate model classes.
  I've already added references to EFProviderWrapperToolkit, EFCachingProvider, EFTracingProvider. I also made changes in my web.config file to :</p>
  
  <pre><code>  &lt;connectionStrings&gt;
      &lt;add name="MyEntities" connectionString="Server=myServer;Database=MyDB;User ID=User;Password=pass;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;" providerName="EFTracingProvider" /&gt;
    &lt;/connectionStrings&gt;
    &lt;system.data&gt;
      &lt;DbProviderFactories&gt;
        &lt;add name="EF Caching Data Provider" invariant="EFCachingProvider" description="Caching Provider Wrapper" type="EFCachingProvider.EFCachingProviderFactory, EFCachingProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=def642f226e0e59b" /&gt;
        &lt;add name="EF Tracing Data Provider" invariant="EFTracingProvider" description="Tracing Provider Wrapper" type="EFTracingProvider.EFTracingProviderFactory, EFTracingProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=def642f226e0e59b" /&gt;
        &lt;add name="EF Generic Provider Wrapper" invariant="EFProviderWrapper" description="Generic Provider Wrapper" type="EFProviderWrapperToolkit.EFProviderWrapperFactory, EFProviderWrapperToolkit, Version=1.0.0.0, Culture=neutral, PublicKeyToken=def642f226e0e59b" /&gt;
      &lt;/DbProviderFactories&gt;
    &lt;/system.data&gt;
  </code></pre>
  
  <p>But when app start, it throws an error in DbConnectionWrapper from EFProviderWrapperToolkit
  in line:</p>
  
  <pre><code>DbProviderFactory factory = DbProviderFactories.GetFactory(providerInvariantName);
  </code></pre>
  
  <p>This is class which inherits from DbContext:</p>
  
  <pre><code>public class MyEntities : DbContext
  {
      public MyEntities()
          : base("MyEntities")
      {
  
      }
  
      protected override void OnModelCreating(DbModelBuilder modelBuilder)
      {
          modelBuilder.Conventions.Remove&lt;IncludeMetadataConvention&gt;();
          modelBuilder.Entity&lt;Product&gt;().ToTable("Product");
          modelBuilder.Entity&lt;ProductPhoto&gt;().ToTable("ProductPhoto");
  
  
          base.OnModelCreating(modelBuilder);
      }
  
      public DbSet&lt;Product&gt; Product { get; set; }
      public DbSet&lt;ProductPhoto&gt; ProductPhoto { get; set; }
  }
  </code></pre>
  
  <p>I've already read post: <a href="http://blog.3d-logic.com/2012/03/31/using-tracing-and-caching-provider-wrappers-with-codefirst/" rel="nofollow">USING TRACING AND CACHING PROVIDER WRAPPERS WITH CODEFIRST</a>, but it didn't solve my problem. </p>
  
  <p>Does anyone know how to do it ?</p>