ASP Boilerplate problems using Effort in unit testing with EFProf (Entity Framework Profiler)


Having issues using EFProf ( with ASP Boilerplate (

For unit testing, ASP Boilerplate uses Effort ( for mocking the database in-memory.

If I run the unit tests without adding the reference to EFProf, the tests run correctly (green).

If I add the initialization line:


in either my test base ctor or my application project's Initialize(), I get the following error:


ComponentActivator: could not instantiate MyApp.EntityFramework.MyAppDataContext

The inner exception has the relevant information:

Error: Unable to cast object of type 'Effort.Provider.EffortConnection' to type 'HibernatingRhinos.Profiler.Appender.ProfiledDataAccess.ProfiledConnection'.

Is Effort just not compatible with EFProf? Or am I doing something blindingly obvious wrong in my initialization?

Accepted Answer

Answering my own question: Effort fakes the DbContect object but does not actually create SQL for in-memory, thus there is nothing to intercept by profilers. It is also the reason why the CommandText is always null when using EF6's Database.Log with Effort.

Am going to try using Moq with EF6 to use an in-memory database implementation for testing as an alternative to Asp Boilerplate's testing project that utilizes Effort per this article:

Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why