ASP Boilerplate problems using Effort in unit testing with EFProf (Entity Framework Profiler) effort entity-framework entity-framework-6 unit-testing


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?

1/30/2017 5:05:35 AM

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:

1/31/2017 8:56:01 AM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow