2012-02-16 29 views
0

我想要建立我的第一個MVC應用程序的教程here 一切都很好,直到我需要運行應用程序時,一個實體框架應該完成它的事情併爲我創建數據庫,但出於某種原因,我總是得到相同的錯誤:如何設置MVC應用程序使用SQL Server 2008 R2的快遞

提供程序沒有返回ProviderManifestToken字符串。

我的問題: 爲了使應用程序正常工作,我需要做些什麼必要的調整?

這裏是我的web.config文件中的連接字符串部分

<connectionStrings> 
<add name="ApplicationServices" 
    connectionString="data source=Moran-Laptop;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" 
    providerName="System.Data.SqlClient" /> 
<add name="MovieDBContext" 
    connectionString="Data Source=|DataDirectory|Movies.sdf" 
    providerName="System.Data.SqlServerCe.4.0"/> 

+1

還有幾個其他關於此錯誤的stackoverflow線程。你有沒有嘗試過他們建議的? http://stackoverflow.com/questions/5423278/ef-4-1-exception-the-provider-did-not-return-a-providermanifesttoken-string – 2012-02-16 14:31:50

+1

似乎是一個副本:http://stackoverflow.com/ questions/5423278/ef-4-1-exception-the-provider-did-not-return-a-providermanifesttoken-string – Vedran 2012-02-16 14:32:30

+0

您是否已閱讀鏈接頁面上的評論?有幾個提到'ProviderManifestToken'爲什麼他們有這個問題以及他們如何修復它。我不是故意的,只要確保他們的解決方案都不適用於您。 – Nope 2012-02-16 14:33:10

回答

0

我覺得您的數據源是不正確的。它的工作原理與:

<add name="ApplicationServices" 
    connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" 
    providerName="System.Data.SqlClient" /> 
+0

我已經安裝了sql server compact 4,但現在我正在收到另一條消息。在我看來,它似乎沒有盡頭。我會找到一個不同的教程,謝謝 – 2012-02-16 15:16:40

0

如果檢查異常,你會發現,有是的InnerException以及其最有可能指向SQLEXCEPTION和無法找到數據庫或服務器。你的ConnectionString希望你的App_Data文件夾中有Sql Server CE數據庫。您正在查看的教程尚未告訴您必須將新的SQL Server CE數據庫添加到App_Data文件夾。檢查部5教程http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/getting-started-with-mvc3-part5-cs

+1

EF應該爲我自動創建這個數據庫,我想。 – 2012-02-16 14:44:29

+0

檢查您正在接收的異常的內部異常。可能是您的計算機上未安裝SQL Server CE。 – 2012-02-16 14:48:02

0

首先你需要改變你的連接字符串,使其指向的SQL Server服務器實例,而不是你的筆記本電腦

在連接字符串與「服務器 - 莫蘭替換,筆記本電腦名稱\數據庫名稱「即r2008sqlserver \電影

相關問題