【问题标题】:Setup of mvc-mini-profiler for EF-db- first为 EF-db- first 设置 mvc-mini-profiler
【发布时间】:2011-07-27 10:54:22
【问题描述】:

我正在尝试将小型分析器与旧式 EF 代码一起使用 - 数据库优先。

到目前为止:

  • 我使用以下方法创建了一个数据库上下文:

        string connectionString = GetConnectionString();
        var connection = new EntityConnection(connectionString);
        var profiledConnection = ProfiledDbConnection.Get(connection);
        _context = profiledConnection.CreateObjectContext<MyEntitiesType>();
    
  • 但随后我点击“无法找到请求的 .Net Framework 数据提供程序。它可能未安装。” 我使用 &lt;system.data&gt; 对 MvcMiniProfiler 提供程序的引用来解决这个问题:

     <system.data>
       <DbProviderFactories>
         <remove invariant="MvcMiniProfiler.Data.ProfiledDbProvider" />
         <add name="MvcMiniProfiler.Data.ProfiledDbProvider" invariant="MvcMiniProfiler.Data.ProfiledDbProvider" description="MvcMiniProfiler.Data.ProfiledDbProvider" type="MvcMiniProfiler.Data.ProfiledDbProviderFactory, MvcMiniProfiler" />
        </DbProviderFactories>
      </system.data>
    
  • 但是现在我在C:\Users\sam\Desktop\mvc-mini-profiler\MvcMiniProfiler\Data\ProfiledDbProviderServices.cs 的某个地方遇到了堆栈溢出。看着latest source,我想知道我是否以某种方式设置错误 - 如果我的配置文件连接包含另一个配置文件连接包含....

有什么帮助/建议吗?


更新 - 查看http://code.google.com/p/mvc-mini-profiler/wiki/FrequentlyAskedQuestions 至少有其他人看到了 1.7 的相同问题 - 尽管他(s)首先编写代码。我会继续玩,看看我能不能弄清楚该怎么做......

【问题讨论】:

  • 这有帮助吗? benjii.me/2011/07/… 有另一种关于配置 EF 的方法的提议
  • 也许 - 必须试一试 - 要么发生在明天深夜或周五(明天一整天在客户站点)
  • 你有没有想过如何首先使用 EF 数据库进行设置?
  • @RyanW - 不 - 我想我会下载源代码并在某个时候正确尝试(抱歉耽搁了 - 一直在休息)

标签: entity-framework mvc-mini-profiler


【解决方案1】:

试试 1.9。通过更新,我刚刚在 Application_Start 中添加了新的 Initialize 方法并删除了 DbProviderFactories 配置部分,现在我可以使用 EF 进行 SQL 分析(甚至有 2 个数据库,一个首先使用代码,一个使用数据库优先)。

protected void Application_Start()
{
    ....other code

    MiniProfilerEF.Initialize();
}

【讨论】:

  • 好的——好消息——它似乎已经修复了!谢谢瑞安W。
  • @RyanW 猜你没试过 Oracle 数据库,对吧?
  • 似乎在当前版本 2.1.0 上运行良好,首先使用数据库。
  • @JamesSkemp 似乎不是,见this
  • @VahidND - 有趣。那天我已经把它和一个新项目联系起来了。
猜你喜欢
  • 1970-01-01
  • 2011-10-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多