【问题标题】:Mini-Profiler crashes on dbo.__MigrationHistory with EF-DB FirstMini-Profiler 在 dbo 上崩溃。__MigrationHistory 与 EF-DB First
【发布时间】:2013-08-13 15:47:39
【问题描述】:

我的 MVC3 应用程序存在一些性能问题。这就是我决定实施迷你分析器的原因。

我将 MVC3 与 EF(和 Razor Views)一起使用。因为我使用的是 DB-first 方法,所以没有 dbo.__MigrationHistory。那么如何让 Mini-Profiler 停止查找呢?

这就是我所做的:

Global.asax.cs:

        protected void Application_Start()
        {
            ...
            MiniProfilerEF.Initialize();
        }

        void Application_BeginRequest(object sender, EventArgs e)
        {
            ...
            MiniProfiler.Start();
        }

        protected void Application_EndRequest()
        {
            MiniProfiler.Stop();
        }

我尝试了answer in this Question,但我无法在我的 DBContext (DAL) 中使用“数据库”。

【问题讨论】:

    标签: asp.net asp.net-mvc-3 entity-framework mvc-mini-profiler


    【解决方案1】:

    试试这个:

    System.Data.Entity.Database.SetInitializer<CMDBContext>(null);
    

    您似乎有一个名为 Database like 的现有属性

        public new string  Database { get; set; }
    

    在您的 CMDBContext 中。然后,当您引用数据库时,您指的是该属性。由于它是对象的属性,因此您无法从静态方法/构造函数中访问它。

    【讨论】:

    • 现在很明显...谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-30
    • 1970-01-01
    相关资源
    最近更新 更多