2012-04-01 76 views
0

我有一個應用程序運行在ASP.NET MVC 3與實體框架代碼優先。在開發過程中,我使用了一個SQL Compact數據庫,但是在將它移動到我的虛擬服務器時,我試圖定位SQL Express。無法找到請求的.Net Framework數據提供程序。它可能沒有安裝

最初有一些問題需要處理「CREATE DATABASE in master」錯誤,我通過將模型從SQL Compact數據庫提取到SQL腳本中並在服務器上執行該腳本來創建數據庫。

我創建了一個新的連接字符串在SQL Express實例,以點帶面,它採用了EF格式:

<add name="LouiseClarkEntities" connectionString="metadata=res://*/Models.LouiseClark.csdl|res://*/Models.LouiseClark.ssdl|res://*/Models.LouiseClark.msl;provider=System.Data.EntityClient;provider connection string=&quot;Data Source=.\SQLEXPRESS; Initial Catalog=LouiseClark; User ID=<username>; Password=<password>&quot;" providerName="System.Data.EntityClient" /> 

錯誤導航到使用一個數據庫中的網頁時,我現在越來越是:

Unable to find the requested .Net Framework Data Provider. It may not be installed. 

我已經在服務器上安裝了Entity Framework 4.1,試試看看這是否能解決問題,但它似乎沒有太大的好處。

從堆棧跟蹤摘錄錯誤頁面:

[ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be installed.] 
    System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName) +1420567 
    System.Data.EntityClient.EntityConnection.GetFactory(String providerString) +35 

[ArgumentException: The specified store provider cannot be found in the configuration, or is not valid.] 

任何幫助,將不勝感激,因爲這已被竊聽我幾天了!

感謝,

克里斯

回答

0

首先使用的代碼的正常連接字符串。

<add name="LouiseClarkEntities" connectionString="Data Source=.\SQLEXPRESS; Initial Catalog=LouiseClark; User ID=<username>; Password=<password>" providerName="System.Data.SqlClient" /> 
+0

謝謝@Eranga但是現在我的自定義初始化器中的context.Database.CompatibleWithModel(false)'調用返回false。我已將元數據表從開發數據庫複製到服務器,並且表匹配。 – Chris 2012-04-01 13:16:36

0

關於第二個問題,第一過的部分原因......

你做錯了什麼是which I got around by extracting the model from the SQL Compact database into an SQL script and executing that on the server to create the DB.

您應該使用該遷移腳本 - 在PM控制檯使用然後Update-Database -Script轉儲出你需要的東西 - 然後將其部署到服務器數據庫。

問題是CF有自己的表和需要正確初始化的數據。如果那不匹配,你會得到類似的東西。

相關問題