Ok, I got it figured out. Here is how to setup your N-Tier projects to support MiniProfiler:
Web Layer - Add a reference to MiniProfiler, MiniProfiler.MVC, MiniProfiler.EntityFramework and BLL Project. In the Global.asax, make sure to turn on EF Profiling:
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
// Entity Framework Profiling
MiniProfilerEF.Initialize();
}
Here is an example of a controller calling the BLL with profiling:
[HttpGet]
public ActionResult Index()
{
var profiler = MiniProfiler.Current;
using (profiler.Step("Web Controller"))
{
Employee bll = new Employee();
int value = bll.GetLastEmployeeID();
}
return View();
}
BLL - Add a reference to MiniProfiler and the DAL Project. BLL methods make a call to the DAL methods.
Here is an example of the a BLL method calling the DAL with profiling:
public int GetLastEmployeeID()
{
int result = 0;
var profiler = MiniProfiler.Current;
using (profiler.Step("BLL - GetLastEmployeeID"))
{
EmployeeDAO dao = new EmployeeDAO();
result = dao.GetLastEmployeeID();
}
return result;
}
DAL - Add a reference to MiniProfiler and MiniProfiler,EF5. DAL methods make a call to the database using Linq. For example:
public int GetLastEmployeeID()
{
int id = 0;
using (var context = new CompanyEntities())
{
var lastEmployee = (from e in context.Employees
where e.IsDeleted == false
orderby e.EmployeeID descending
select e).First();
id = lastEmployee.EmployeeID;
}
return id;
}
Using this setup, I am able to get the EF profiling with SQL to display in MiniProfiler on the Web Site.