Search code examples
asp.net-mvclinq-to-sqlmvc-mini-profiler

Configure Mvc Mini Profiler with Linq DataCotext


I'm using linq-to-sql datacontext for an application. I have the following class

UserDataContext which I instantiate the table with

var db = new UserDataContext();

How do I make Mvc Mini Profiler insert into that?

I tried to extend UserDataContext with the following partial found at another answer, but the code is never hit.

partial class UserDataContext
{    
public static UserDataContext Get()
    {
        var sqlConnection = new HelpSaudeAPDataContext().Connection;
        var profiledConnection = new MvcMiniProfiler.Data.ProfiledDbConnection(new SqlConnection("UserConnectionString"), MiniProfiler.Current);
        return new HelpSaudeAPDataContext(profiledConnection);
    }
}

Unfortunately there is no single point repository with the var db connection where I could simply pass the mvc mini profiler connection with.

var db = UserDataContext(profilerConnection);

Solution

  • but the code is never hit.

    Well, hit it:

    var db = UserDataContext.Get();