# Mini Profiler and Linq2DB in .NET MVC

**URL:** <https://community.miniprofiler.com/t/mini-profiler-and-linq2db-in-net-mvc/583>\
**Category:** .NET\
**Created:** [January 12, 2018, 1:04am UTC](https://community.miniprofiler.com/t/mini-profiler-and-linq2db-in-net-mvc/583 "2018-01-12T01:04:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kershaw](https://avatars.discourse-cdn.com/v4/letter/k/96bed5/32.png) [@Kershaw](https://community.miniprofiler.com/u/Kershaw)\
**Post date:** [January 12, 2018, 1:04am UTC](https://community.miniprofiler.com/t/mini-profiler-and-linq2db-in-net-mvc/583/1 "2018-01-12T01:04:34Z")

</div>

I have a task to add miniprofiler to a .NET MVC 5 application. So far I have done this and it works:

- Installed NuGet packages for MiniProfiler and MiniProfiler.MVC4

- Added @MiniProfiler.RenderIncludes() to shared View:

- Added necessary start and stop code to Global.asax.cs:

- Added necessary methods to ControllerBase.cs (OnActionExecuting, OnResultExecuting, and OnResultExecuted)

- Added handler to web.config:

With this basic setup I get the profiler results to display on all of my views. Works great and is easy to setup!

The next step is to profile the database. I see support for several db platforms, but I have not found much for Linq2DB.

In this project we have a context class that looks something like:

```
public class SomeAppContext : DataConnection
{
    public ITable<Category> Categories { get { return this.GetTable<Category>(); } }
    public ITable<Meeting> Meetings { get { return this.GetTable<Meeting>(); } }

    public SomeAppContext() : base("SomeAppContext")
    {
    }

    public SomeAppContext(string configuration) : base(configuration)
    {
    }
}

```

Example db call would be something like:

```
public bool IsMeetingConcluded(int meetingID)
{
    using (var context = new SomeAppContext())
    {
        var meeting = context.Meetings.Where(x => x.MeetingID == meetingID).FirstOrDefault();
        
        if(meeting!=null)
        { 
            if(DateTime.Today > meeting.EndDate)
            {
                return true;
            }
        }
        return false;
    }
}

```

What do I need to do to get Mini Profiler to work with the above code?

Thx

---

<div class="post-metadata">

**Author:** ![Kershaw](https://avatars.discourse-cdn.com/v4/letter/k/96bed5/32.png) [@Kershaw](https://community.miniprofiler.com/u/Kershaw)\
**Post date:** [January 12, 2018, 11:07pm UTC](https://community.miniprofiler.com/t/mini-profiler-and-linq2db-in-net-mvc/583/2 "2018-01-12T23:07:46Z")

</div>

In case someone else can benefit from this question, I am posting the solution that I found today.

- If you haven’t already, add the linq2db NuGet package.

- Another thing to do is to add AllowMultipleQuery setting to Global.asax.cs Application\_Start():

- Also, I updated the context class to this, and now the views have in the profiler output the sql one liner showing time in ms, as well as the links to click and display all the sql query details as well as duplicates, etc.

- Keep in mind you may need to use a different SqlServerDataProvider, mine is SqlServerVersion.v2008, but here is the enum of supported providers:
