I have an ASP.Net MVC application with Entity Framework. I have used Structuremap V4.4 as IoC Container tool.
I want to make an instance of DbContext in each request.
My configuration is as follows:
var unique = new UniquePerRequestLifecycle();
For<ContextDB>().LifecycleIs(unique)
.Use<ContextDB>().Transient();
And I use it like this everywhere:
public UserRepository(ContextDB context) : base(context)
{
}
But, when I profile the project with EFProfiler, it is not One DbContext
!!
What is the problem here?
What should I do?