我有一个带有Entity Framework的 ASP.Net MVC应用程序。我使用 Structuremap V4.4作为IoC容器工具。
我想在每个请求中创建一个DbContext实例。
我的配置如下:
var unique = new UniquePerRequestLifecycle();
For<ContextDB>().LifecycleIs(unique)
.Use<ContextDB>().Transient();
我随处可见:
public UserRepository(ContextDB context) : base(context)
{
}
但是,when I profile the project with EFProfiler, it is not One DbContext
!!
这里有什么问题?
我该怎么办?