Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MiniProfiler with EntityFramework 6 code first

I have tried to wire-up a MiniProfiler to an existing project which used EF6 code first, aaaand it just makes me crazy now :)

The problem is that by default MiniProfiler works with EF 4.1, and for 6.0 they have implemented kind of quick solution https://github.com/SamSaffron/MiniProfiler/pull/134

But seems like it doesnt works for me. Everytime I'm launching application I just getting the following exception:

System.InvalidOperationException: The Entity Framework provider type 'StackExchange.Profiling.Data.EFProfiledSqlClientDbProviderServices, MiniProfiler.EntityFramework6' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.

Did anybody faced similar issue? Thank you!

like image 959
user3046346 Avatar asked Oct 03 '22 07:10

user3046346


1 Answers

The EF6 nuget has been published. It is available here and can be installed using Install-Package MiniProfiler.EF6 -Pre

To initialize, simply call the following in your application startup logic:

using StackExchange.Profiling.EntityFramework6;

...

protected void Application_Start()
{
    MiniProfilerEF6.Initialize();
}

Be sure to call this before using EF in any way.

like image 186
Yaakov Ellis Avatar answered Oct 07 '22 19:10

Yaakov Ellis