Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you configure mvc-mini-profiler with EF 4.2 Code first

EF 4.1 Update 1 had an error in it with regards to profiling that has now been fixed and I am trying to get profiling working using MySql with EF 4.2 Code First.

I tried putting

MiniProfilerEF.Initialize();

in my application start but received the error

Unable to find the requested .Net Framework Data Provider. It may not be installed.

like image 928
runxc1 Bret Ferrier Avatar asked Nov 03 '11 22:11

runxc1 Bret Ferrier


1 Answers

http://code.google.com/p/mvc-mini-profiler/

EF 4.1 Update 1

Note, that EF 4.1 Update 1 (version currently on NuGet) has a breaking change which throws the following error when specifying a connection string:

The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)

MiniProfiler attempts to resolve this issue by detecting the version of EntityFramework that it is running against. If this doesn't work (due to security exceptions), force the hack to be applied by replacing the Initialize() call with:

MiniProfilerEF.Initialize_EF42(); // in Application_Start

However, this is currently unable to profile SqlCE or Oracle databases.

To work around this an additional parameter has been added to the Initialize call:

If you specify connection strings explicitly in your web.config, use MiniProfilerEF.Initialize();. This will not profile SqlCE or Oracle databases If you don't specify connection strings (automatically inferred) and want SqlCE support, use MiniProfilerEF.Initialize(false);. Note, this should be a temporary solution until EF 4.2 is widely available.

like image 83
Matthew Perron Avatar answered Oct 21 '22 23:10

Matthew Perron