我有一个 Asp.net Mvc 3 应用程序,它现在正在使用 MvcMiniProfiler。我还使用实体框架来访问我的数据库,并且我想让探查器能够使用实体模型。到目前为止,我已经在下面创建了 Context 工厂:
internal class ProfiledContextFactory : IContextFactory
{
public ModelContainer GetContext()
{
var conn = ProfiledDbConnection.Get(GetConnection());
return ObjectContextUtils.CreateObjectContext<ModelContainer>(conn);
}
private static EntityConnection GetConnection()
{
return new EntityConnection(ConfigurationManager.ConnectionStrings["ModelContainer"].ConnectionString);
}
}
当我运行上面的代码时,当我启动一个工作单元时,它由我的存储库层调用,当我在 MvcMiniProfiler.ProfiledDbServices 类中调用 CreateDbCommandDefinition 时,它会陷入无限循环。
任何线索我做错了什么?