2012-01-26 54 views
2

我已經搜遍了堆棧溢出帖子,但至今沒有運氣。我已經開始使用Entity Framework 4.2的新MVC 3項目。我用nuget安裝MiniProfiler,MiniProfiler.MVC3和MiniProfiler.EF(MiniProfiler.EF也添加到我的域圖層)。沒有分析實體框架,一切工作正常。當我取消註釋行MiniProfilerEF.Initialize();簡介EF,我得到的錯誤:無法使用mvc mini profiler與EF 4.2配合使用

類型「MvcMiniProfiler.Data.EFProfiledDbConnection」的指定店鋪連接的供應工廠可能不會被發現。在定義了'MvcMiniProfiler.Data.EFProfiledDbConnection'的程序集中註冊的提供程序工廠和所有提供程序工廠都會搜索能夠產生匹配連接的工廠。

我試着獲取最新的源代碼,因爲我讀EF 4.1的更新需要它。現在,當我運行該項目時,出現錯誤:

無法確定連接類型爲'MvcMiniProfiler.Data.EFProfiledDbConnection'的提供程序名稱。

我經歷過的文檔有點令人困惑,因爲我不能說出什麼是新的,什麼是舊的。從this post看來我需要修改web.config中的任何內容。我錯過了另一個步驟嗎?謝謝您的幫助。

+0

你試過軀幹和新intialization常規 –

+0

感謝您的答覆薩姆。我應該以我剛剛接觸mini-profiler作爲序言,所以感謝你的支持。我得到了主幹並運行了Sample.MVC項目。 sql分析在SQLite連接上效果很好。當我點擊家用控制器上的EF Code First Ajax Request時,我看不到使用「插入路由」步驟執行的「First Count」和「Insertion」分析步驟的sql查詢和調用堆棧。我知道在過去,配置連接必須與DbContext ctor一起提供,但是從我可以收集的信息來看,這不再需要。我錯過了什麼? – Manny

+0

@Manny有類似的問題(無法確定連接類型的提供程序名稱...)。你知道了嗎? – Pandincus

回答

0

在Web.config文件中是否有此項?

<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.EntityFramework, Version=1.9.1.0, Culture=neutral, PublicKeyToken=b44f9351044011a3" /> 
    </DbProviderFactories> 
    </system.data> 
1

你應該把MiniProfilerEF.Initialize();之前的任何訪問數據庫:

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

     // Start access database from here ... 
     // For example call MyDbContext.Database.Exists(); 
}