mishrsud / mvc-mini-profiler

Automatically exported from code.google.com/p/mvc-mini-profiler
0 stars 0 forks source link

Stack overflow in CreateDbCommandDefinition when using EF 4.0 #32

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I'm am using EF and I'm getting a stack overflow on the first line of 
CreateDbCommandDefinition. I've traced the issue down to the 
ProfileDbProviderFactory for the method GetService. For some reason this method 
is being called repeatedly and for EF it keeps calling the line

svc = new ProfiledDbProviderServices((DbProviderServices)svc, profiler);

I'm not sure what else is going on after this step but then 
CreateDbCommandDefinition gets called after that. This continues until the 
stack fills up. 

Original issue reported on code.google.com by mendoza....@gmail.com on 20 Jun 2011 at 5:14

GoogleCodeExporter commented 8 years ago
Fixed: I was creating an EntityConnection object and giving  
MvcMiniProfiler.Data.ProfiledDbConnection.Get an Entity connection. I instead 
made a SqlConnection object with a normal connection string and passed that to 
the Get function. That worked great with my EF model.

var sqlConn = new SqlConnection(connStr);
var profiledConnection = MvcMiniProfiler.Data.ProfiledDbConnection.Get(sqlConn, 
this.Profiler);
return 
ObjectContextUtils.CreateObjectContext<Detectent.DataAccess.Cust.CustEntities>(p
rofiledConnection);

Original comment by mendoza....@gmail.com on 20 Jun 2011 at 6:28

GoogleCodeExporter commented 8 years ago
I had the same problem.  But your solution of using the SqlConnection doesn't 
work for me because I am already wrapping my connection so that I can do some 
logging via 
http://blogs.msdn.com/b/jkowalski/archive/2009/06/11/tracing-and-caching-in-enti
ty-framework-available-on-msdn-code-gallery.aspx

Original comment by robson.k...@gmail.com on 5 Jul 2011 at 3:11

GoogleCodeExporter commented 8 years ago
Just checked in this method for tracing EF 
http://benjii.me/2011/07/using-the-mvc-mini-profiler-with-entity-framework/

assume it is resolved

Original comment by sam.saff...@gmail.com on 15 Aug 2011 at 1:08

GoogleCodeExporter commented 8 years ago

Original comment by sam.saff...@gmail.com on 15 Aug 2011 at 1:08