I'm trying to get MiniProfiler to profile my database access but I'm running into problems. All the help I see out there seems to be for "code first" entity framework connections. My model was designed before the code first update was available this year and I used the designer to create the edmx model. (I've been using this for almost a year and it seems to be working for me)
The example on the MiniProfiler documentation site doesn't make sense to me. I've tried a few variations of it but I'm having problems.
My Model is called CYEntities, normally to instantiate an ObjectContext I just do this
var context = new CYEntities()
here's what I've tried for the profiler...
var dbConnection = new CYEntities().Connection;
var profiledConnection = ProfiledDbConnection.Get(dbConnection);
var context = profiledConnection.CreateObjectContext<CYEntities>(); // this is the context I'd finally use to access data.
This throws an exception...
System.ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be installed.
I'm not sure where to go from here.
Try like this:
var connectionString = ConfigurationManager
.ConnectionStrings["MyConnectionString"]
.ConnectionString;
var ecsb = new EntityConnectionStringBuilder(connectionString);
var sqlConn = new SqlConnection(ecsb.ProviderConnectionString);
var pConn = ProfiledDbConnection.Get(sqlConn, MiniProfiler.Current);
var context = ObjectContextUtils.CreateObjectContext<CYEntities>(pConn);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With