Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6642483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:56:09+00:00 2026-05-25T23:56:09+00:00

Today I’ve dropped back into a project that I haven’t been working with for

  • 0

Today I’ve dropped back into a project that I haven’t been working with for the past month or so. I had this project configured using MiniProfiler 1.7 and all was well in the world. It profiled my DB calls and the view performance as well.

I decided to upgrade to 1.9 and I’ve run into a few speed bumps. Now, I’ve worked through most of the issues at this point. The only thing that seems “wrong” is DB profiling. I’m getting dropped a yellow screen of death with the following error:

A null was returned after calling the 'get_ProviderFactory' method on a store 
provider instance of type 'MvcMiniProfiler.Data.ProfiledDbConnection'. 
The store provider might not be functioning correctly.

For reference, let me show you how I had miniprofiler setup in 1.7 with MVC3 and EF 4.1 Code First.

web.config

  <system.data>
<DbProviderFactories>
  <remove invariant="MvcMiniProfiler.Data.ProfiledDbProvider" />
  <add name="MvcMiniProfiler.Data.ProfiledDbProvider" 
       invariant="MvcMiniProfiler.Data.ProfiledDbProvider" 
       description="MvcMiniProfiler.Data.ProfiledDbProvider" 
       type="MvcMiniProfiler.Data.ProfiledDbProviderFactory, MvcMiniProfiler, Version=1.7.0.0, Culture=neutral, PublicKeyToken=b44f9351044011a3" />
</DbProviderFactories>

Global.asax handled most everything from there. I’ll list the relevant Application_Start() code that worked prior that doesn’t now.

#region MVC Mini Profiler related database profiling config/setup

        //This line makes SQL Formatting smarter so you can copy/paste 
        // from the profiler directly into Query Analyzer
        MiniProfiler.Settings.SqlFormatter = new SqlServerFormatter();

        var factory = new SqlConnectionFactory(ConfigurationManager.ConnectionStrings["Database"].ConnectionString);
        var profiled = new ProfiledDbConnectionFactory(factory);
        Database.DefaultConnectionFactory = profiled;

#endregion

With the last step being in my context hooking in the profiled connection:

public class Database : DbContext
{
    public Database()
        : base(GetProfilerConnection(), true)
    {}

    private static DbConnection GetProfilerConnection()
    {
        return
            ProfiledDbConnection.Get(
                new SqlConnection(ConfigurationManager.ConnectionStrings["Database"].ConnectionString));
    }
}

Fast forward to today and I’ve reworked things to use the MVC3 minprofiler nuget package and the EF miniprofiler NuGet package, but I’m lost on how to get DB profiling working again.

I’ve modified my web.config to the following which seemed to be what was required but ReSharper isn’t happy first off.

  <system.data>
<DbProviderFactories>
  <remove invariant="MvcMiniProfiler.Data.ProfiledDbProvider" />
  <add name="MvcMiniProfiler.Data.ProfiledDbProvider" invariant="MvcMiniProfiler.Data.ProfiledDbProvider"
       description="MvcMiniProfiler.Data.ProfiledDbProvider"
       type="MvcMiniProfiler.Data.ProfiledDbProviderFactory, MvcMiniProfiler.EntityFramework, Version=1.9.1.0, Culture=neutral, PublicKeyToken=b44f9351044011a3" />
</DbProviderFactories>

enter image description here

Not quite sure what I’m missing here. Do I even need this anymore with a call to MiniProfilerEF.Initialize();? Some documentation and suggestions seem to indicate you don’t even need this anymore.

The bigger problem is how to setup DB Profiling in 1.9.

The relevant code that I had prior in Global.asax has now been moved into MiniProfiler.cs in the App_Start folder. I figured the setup would have been the same but that doesn’t appear to be the case.

I want to do this (perhaps because this is just what I’m familiar with in 1.7)

//TODO: To profile a standard DbConnection: 
        var factory = new SqlConnectionFactory(ConfigurationManager.ConnectionStrings["Database"].ConnectionString);
        var profiled = new ProfiledDbConnectionFactory(factory);
        Database.DefaultConnectionFactory = profiled;

This doesn’t seem to work any longer. I’ve also noted that it seems I should be using EFProfiledDbConnection now instead of just ProfiledDbConnection? Is this correct?

How do I go about configuring DB profiling with this model? I’m digging high and low through documentation, but there’s so much information with the old way mixed in with the new way and I’m having a hard time separating what the “correct” way is today.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:56:10+00:00Added an answer on May 25, 2026 at 11:56 pm

    Ugh, sorry guys.

    I solved the problem.

    I had to add the EF MVCMiniProfiler NuGet package in my data model project and change the connection type there to EFProfiledConnection as so:

            /// <summary>
        /// Supply our own connection string to the DBContext to utilize mini-profiler for SQL queries as well.
        /// </summary>
        /// <returns>DBConnection</returns>
        private static DbConnection GetProfilerConnection()
        {
            return new EFProfiledDbConnection(new SqlConnection(ConfigurationManager.ConnectionStrings["Database"].ConnectionString),
                                            MiniProfiler.Current);
        }
    

    Guess that should have been obvious to me looking at how EF was broken out into it’s own connection type.

    I also commented out the config settings so I can confirm that they’re no longer required.

    I don’t know if this is the “right” way of configuring EF and MVC Mini 1.9, but it works.

    I’m open to suggestions on improvement or if there’s a more correct way of doing this, but for now I’m back up and running again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Today, I ran into this weird problem with a user using Mac OS X.
Today I had to define the WIN32_MEAN_AND_LEAN preprocessor macro in a native C++ project
Today, reading Servlet 3.0 specification, I've come across a sentence: We emphasize that this
Today I just opened the project I was working on XCODE 4, and only
today I just opened my 1,5 month old project and wanted to add a
Today I was working on a tab navigation for a webpage. I tried the
Today I discovered that my fresh installation of Apache HTTP Server is able to
Today I had a coworker suggest I refactor my code to use a label
Today I had a discussion with a colleague about nested functions in Javascript: function
Today somebody told me that interface implementation in C# is just Can-Do relationship, not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.