I have an issue where we are using EF 4.3 Code First against an existing database. I want to use the Mini-Profiler with EF and call
MvcMiniProfiler.MiniPro
I started a new MVC 4 project and installed/updated the following NuGet packages:
I turned off the database initialization strategy in Code First inside of my database context.
public class EmployeeContext : DbContext
{
static EmployeeContext()
{
Database.SetInitializer( null ); // must be turned off before mini profiler runs
}
public IDbSet Employees { get; set; }
}
The mini profiler is working properly. I created the one table database by hand.
Turning off the database initializer in the static constructor is important. If you do it elsewhere then it's possible that the mini profiler code runs before your code and hence the queries to the __MigrationHistory table that shouldn't be occurring at all.