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 6385513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:54:33+00:00 2026-05-25T02:54:33+00:00

I am trying to setup database profiling with my ASP.NET MVC3 application. I have

  • 0

I am trying to setup database profiling with my ASP.NET MVC3 application. I have followed every blog I can find about this and the result is:

In 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.6.0.0, Culture=neutral, PublicKeyToken=b44f9351044011a3" />
  </DbProviderFactories>
</system.data>

In Global.asax:

protected void Application_Start()
{
    Bootstrapper.Run();

    MiniProfiler.Settings.SqlFormatter = new SqlServerFormatter();

    var factory = new SqlConnectionFactory(ConfigurationManager.ConnectionStrings["TemplateDB"].ConnectionString);
    var profiled = new MvcMiniProfiler.Data.ProfiledDbConnectionFactory(factory);

    Database.DefaultConnectionFactory = profiled;
}

protected void Application_BeginRequest()
{
    if (Request.IsLocal) { MiniProfiler.Start(); } 
}

protected void Application_EndRequest()
{
    MiniProfiler.Stop();
}

In controller:

public ActionResult About()
{
    var profiler = MiniProfiler.Current;

    using (profiler.Step("call database"))
    {
        ProjectResult result = projectService.Create("slug");

        return View();
    }
}

I am using the repository patterns and my EF Code first lives in another project that is referenced by the MVC application.

My database class looks like:

public class Database : DbContext
{
    public Database(string connection) : base(connection)
    {
    }

    public DbSet<Project> Projects { get; set; }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        modelBuilder.Entity<Project>().Property(p => p.Slug).IsUnicode().IsRequired().IsVariableLength().HasMaxLength(64);
    }

    public virtual void Commit()
    {
        base.SaveChanges();
    }
}

My database factory looks like:

public class DatabaseFactory : Disposable, IDatabaseFactory
{
    private readonly string connectionString;
    private Database database;

    public DatabaseFactory(string connectionString)
    {
        Check.Argument.IsNotNullOrEmpty(connectionString, "connectionString");

        this.connectionString = connectionString;
    }

    public Database Get()
    {
        return database ?? (database = new Database(connectionString));
    }

    protected override void DisposeCore()
    {
        if (database != null)
            database.Dispose();
    }
}

When I run my application the profiler will not show any database profiling at all, just the regular execution time of the controller/view.

Any help is appreciated.

Thanks

  • 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-25T02:54:33+00:00Added an answer on May 25, 2026 at 2:54 am

    Solved by installing the Nuget MiniProfiler and MiniProfiler.EF package. Add the following in the Global.asax

    protected void Application_Start()
    {
        MiniProfilerEF.Initialize();
    }
    
    protected void Application_BeginRequest()
    {
        if (Request.IsLocal)
        {
            MiniProfiler.Start();
        } 
    }
    
    protected void Application_EndRequest()
    {
        MiniProfiler.Stop();
    }
    

    And finally add the below code to the head tage below JQuery of your markup.

    @MvcMiniProfiler.MiniProfiler.RenderIncludes()
    

    You’re set. Works like a charm.

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

Sidebar

Related Questions

currently I'm trying to have a setup where a generic database is distributed to
I am trying to setup a simple database in which I have a user
I'm trying to setup rspec for testing in my rails application. I have created
I am new to asp.net mvc3 and trying to get a connection going to
We have the coverity tool setup and are trying to find a way to
I am trying to use the ASP.NET SQL Server Registration Tool to setup my
I'm trying to setup a SQL database for a local program management and install
I am trying to work out the best database model for the current setup:
I'm trying to setup CruiseControl.net at the moment. So far it works nice, but
I'm working with an existing database schema, and trying to setup two Doctrine models

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.