標籤:
webconfig中配置<connectionStrings></connectionStrings>如下:
<connectionStrings>
<add name="GoodPanEntities" connectionString="metadata=res://*/GoodPan.csdl|res://*/GoodPan.ssdl|res://*/GoodPan.msl;provider=System.Data.SqlClient;provider connection string="data source=.\SQLEXPRESS;initial catalog=資料庫名;persist security info=True;
user id=使用者;password=密碼;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
配置後在本地運行正常,上傳到伺服器後出現錯誤,把data source=.\SQLEXPRESS;改成伺服器ip運行正常。
<connectionStrings>
<add name="GoodPanEntities" connectionString="metadata=res://*/GoodPan.csdl|res://*/GoodPan.ssdl|res://*/GoodPan.msl;provider=System.Data.SqlClient;provider connection string="data source=伺服器IP;initial catalog=資料庫名;persist security info=True;
user id=使用者;password=密碼;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
asp.net mvc4 設定資料庫串連的相關問題