# How to setup miniprofiler for database-first entity framework?

**URL:** <https://community.miniprofiler.com/t/how-to-setup-miniprofiler-for-database-first-entity-framework/112>\
**Category:** uncategorized\
**Created:** [June 20, 2012, 10:29am UTC](https://community.miniprofiler.com/t/how-to-setup-miniprofiler-for-database-first-entity-framework/112 "2012-06-20T10:29:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![soleiljy](https://avatars.discourse-cdn.com/v4/letter/s/bcef8e/32.png) [@soleiljy](https://community.miniprofiler.com/u/soleiljy)\
**Post date:** [June 20, 2012, 10:29am UTC](https://community.miniprofiler.com/t/how-to-setup-miniprofiler-for-database-first-entity-framework/112/1 "2012-06-20T10:29:15Z")

</div>

I am trying to use mvc-mini-profiler for db-first EF, but it is not working properly.  
(note that I’m using objectcontext, not dbcontext)

Here is the list of stackoverflows I’ve tried:

- Setup of mvc-mini-profiler for EF-db- first
- How to get MVC-mini-profiler working on EF 4.1 Database First

versions:

- Entity Framework: 4.3.1
- MiniProfiler: 2.0.2
- MiniProfiler.ef: 2.0.3

This is how I setup miniprofiler:

I’ve added the following stuff in Global.asax

```
protected void Application_BeginRequest(
{
     MiniProfiler.Start();   
}

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

protected void Application_Start()
{
    ...

    MiniProfilerEF.Initialize_EF42();
}

```

Then configure an objectcontext,

```
var entityConnection = new EntityConnection(ConnectionString);
var profiledDbConnection = new EFProfiledDbConnection(entityConnection, MiniProfiler.Current);
var context = profiledDbConnection.CreateObjectContext<MyContext>();
var list = context.MyEntities.ToList();

```

If I execute this, the following exception occurs when running “context.MyEntities.ToList()”

[System.Data.EntityCommandCompliationException]

the message in the inner exception says: EntityClient cannot be used to create a command definition from a store command tree.

Have I configured wrong? Any help?

thanks,
