Skip to main content

Tracing and Caching Provider Wrappers for Entity Framework 4

This sample shows how to extend Entity Framework 4 by plugging into the EF's ADO.NET provider interface

C# (1.9 MB)
3.8 Star
24,348 times
Add to favorites
E-mail Twitter Digg Facebook
Sign in to ask a question

  • The provider did not return a DbSpatialServices instance.
    1 Posts | Last post September 06, 2013
    • When the entity include a field which is DbGeometry or DbGeography , it will return a error message "The provider did not return a DbSpatialServices instance."
  • Does tracing work with EF ver.5
    2 Posts | Last post August 06, 2013
    • We have a new ASP.Net MVC4 project using EF ver.5. Will this EFTracingProvider work with ver. 5? Our entity class inherits from DbContext and not ObjectContext so what EFProviderWrapperToolKit class do I use in my Entities constructor so I can inject the providers into the DBContext?
    • I have the same question... options available? 
  • Retrieve the SQL string before execution
    1 Posts | Last post June 18, 2013
    • Hi,
      I have been using this tool and it is great in capturing the SQL statement that EF send to DB. one requirement of the user team is, after they make the change, we need to capture and display the SQL statement that IS GOING TO be applied to DB, and allow a reviewer to review, before sending to database. Is it possible, that we can capture SQL statement that EF is about to execute, but without executing them? For example, changing Name of the BookEntity from "ABC"->"CDE"
      and we can preview this change with SQL statement captured..
  • EFProviderWrapperToolKit with EF6
    1 Posts | Last post May 06, 2013
    • Hi,
      We have used EFProviderWrapperToolkit and developed own customized provider. The main purpose of own provider is to support connection pooling in multi-tenancy scenario. 
      It was working fine with EF4.3 Code First model, but stopped working with EF6. 
      I have posted my issue here:
      It would be great if you can provide some guidance how to use them with EF6 and develop own provider? Or how can we achieve Connection Pooling?
  • Cache expiration from second application
    3 Posts | Last post March 30, 2013
    • I try to use the caching provider in our application with InMemoryCache (no ASP.NET), and it works great. The only issue is that our database also gets updated by a second and third application. Is there a way to let the cache in our primary application expire when there has been an insert or update from the 2nd or 3rd application? Or is there any other way to define the expiration criteria when using InMemoryCache?
      Hope that anybody can answer this question. 
      Thank you and kind regards, Jeroen
    • I have the same question. For now I created a button in my application that just sets the cache to new EFCachingProvider.Caching.InMemoryCache() whenever I want my data to refresh. If you figure out how to make this happen automatically please share your method. Thanks. 
    • I think you have to consider changing your concept.
      Create a ModelLogic project that uses this project and share this modellogic with multiple businesslogic projects.
      Also share the same cache service, now you reuse your entities through your projects.
  • This leaks serious amounts of memory
    1 Posts | Last post January 18, 2013
    • Hi,
      We have been using this to avoid a query bug in Sybase ASA's ADO.NET drivers in our latest version.
      In our environment the application servers works against approx 300-500 databases at the same time which all uses the same EF model (the metadata is on 7MB).
      The problem occurs in normal use since the code in EntityConnectionWrapperUtils stores one metadata for each connectionstring in metadataWorkspaceMemoizer! A simple calculation shows that our memory usage will be approx 500*7MB=3.5GB in this single dictionary!
      Right now we have removed the use of this wrapper from our code to avoid this problem (Sybase has also fixed their problem).
      I just posted this to inform/warn others with large amount of database connections and this will cause serious performance/memory issues.
  • Serialization
    1 Posts | Last post January 02, 2013
    • Hi, I skimmed through the code, but I didn't find any way to handle serialization. Is this a responsibility of the ICache implementation (if serialization is needed, like in the case of Azure distributed cache)? 
      Nicolas KP
  • DB or Cache hit?
    1 Posts | Last post November 28, 2012
    • How do I determine if the query hits the database, or, uses cache to respond to a request? Does anyone even monitor this anymore?
  • Default cache all
    1 Posts | Last post November 28, 2012
    • The example shown states that you must define the cache type and caching policy on context creation... if I'm pretty much going to be enabling the caching policy to InMemoryCache and CacheAll, wouldn't it make more sense to define this in the constructor as default, instead of defining it every time I reference the Extended Entity Class, and if I need to use a different method, override it after context creation?
  • Set schema runtime
    2 Posts | Last post October 11, 2012
    • It is possible to modify the schema at runtime. Use oracle with EF4.
    • I found a solution.
      In class EntityConnectionWrapperUtils.cs
      public static class EntityConnectionWrapperUtils
      public static XNamespace StoreNamespace = "";
      private static MetadataWorkspace CreateWrappedMetadataWorkspace(string metadata, string Schema, IEnumerable<string> wrapperProviderNames)
      if ( !string.IsNullOrWhiteSpace( Schema ) )
                          foreach ( var storeEntitySet in ssdlFile.Descendants( StoreNamespace + "EntitySet" ) )
                              storeEntitySet.Attribute( "Schema" ).Value = Schema;
1 - 10 of 41 Items