簡體   English   中英

app.config和用於遠程連接的實體框架

[英]app.config and Entity Framework for remote connection

我有一個可以正常工作的本地數據庫的連接字符串。

<connectionStrings>

    <add name="Entities" 
         connectionString="metadata=res://*/RNADataModel.csdl|
                    res://*/RNADataModel.ssdl|
                    res://*/RNADataModel.msl;
                    provider=System.Data.SqlClient;
                    provider connection string=&quot;
                    Data Source=my-localhost;
                    Initial Catalog=my-db-name;
                    Integrated Security=True;                        
                    multipleactiveresultsets=True;
                    App=EntityFramework&quot;"
         providerName="System.Data.EntityClient"/>
  </connectionStrings>

但是我不知道如何成功連接到遠程數據庫。 我試圖添加User ID=user ; Password=pass; 並且還禁用了Integrated Security但是服務器無法連接。

有沒有辦法修復連接字符串或其他解決方法以連接到遠程數據庫?

編輯 :每次未正確指定連接字符串時,錯誤均來自我的Web應用程序:

Server Error in '/' Application.
The server was unable to process the request due to an internal error.  For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs. 

System.Data.EntityException引發: {"The underlying provider failed on Open."}

如果使用SQL Server Management Studio,則可以看到服務器上的數據庫,並且憑據可以正常運行。 可能是一些防火牆配置,有什么建議嗎?

您需要將Data Source = my-localhost更改為Data Source = ServerName \\ InstanceName不要忘記指定正確的用戶名和密碼

我設法訪問了客戶的服務器,因此請按照本指南http://blogs.msdn.com/b/walzenbach/archive/2010/04/14/how-to-enable-remote-connections-in-sql-server- 2008.aspx我已啟用遠程連接。 連接字符串很好。 謝謝評論

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM