0

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?

Prashanth Benny
  • 1,523
  • 21
  • 33
Saeid Mirzaei
  • 950
  • 2
  • 18
  • 48

0 Answers0