简体   繁体   English

app.config和用于远程连接的实体框架

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

I have a connection string to a local database which works ok. 我有一个可以正常工作的本地数据库的连接字符串。

<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>

However I cannot figure how to connect to a remote database succesfully. 但是我不知道如何成功连接到远程数据库。 I have tried to add User ID=user ; 我试图添加User ID=user ; Password=pass; and also disabled Integrated Security but the server fails to connect. 并且还禁用了Integrated Security但是服务器无法连接。

Is there a way to fix the connection string or some other workaround to connect to the remote database? 有没有办法修复连接字符串或其他解决方法以连接到远程数据库?

EDIT : The error comes from my web app every time the connection string is not correctly specified: 编辑 :每次未正确指定连接字符串时,错误均来自我的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. 

and

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

If I use SQL Server management studio I can see the database on the server and credentials works fine. 如果使用SQL Server Management Studio,则可以看到服务器上的数据库,并且凭据可以正常运行。 Might be some firewall configuration, any suggestions? 可能是一些防火墙配置,有什么建议吗?

您需要将Data Source = my-localhost更改为Data Source = ServerName \\ InstanceName不要忘记指定正确的用户名和密码

I managed to access the customer's server, so following this guide http://blogs.msdn.com/b/walzenbach/archive/2010/04/14/how-to-enable-remote-connections-in-sql-server-2008.aspx I have enabled the remote connection. 我设法访问了客户的服务器,因此请按照本指南http://blogs.msdn.com/b/walzenbach/archive/2010/04/14/how-to-enable-remote-connections-in-sql-server- 2008.aspx我已启用远程连接。 The Connection string was fine. 连接字符串很好。 Thanks the comments 谢谢评论

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 App.Config中的实体框架连接字符串 - Entity Framework Connection String in App.Config 实体框架未在app.config中使用连接字符串 - Entity Framework not using connection string in app.config 在Entity Framework的app.config中更改连接字符串 - Changing connection string in app.config for Entity Framework 在app.config中找不到实体框架连接字符串 - Can't Find Entity Framework Connection String in app.config 未创建实体框架 6 App.config 文件 - Entity Framework 6 App.config file is not created 没有App.config的SQLite实体框架 - SQLite Entity Framework without App.config 实体框架(代码优先到现有数据库)-在运行时覆盖app.config中的连接字符串 - Entity Framework(Code First to an existing database) - overwrite a connection string in app.config at runtime 强制实体框架和ASP.MVC使用另一个程序集的app.config中的连接字符串 - Forcing Entity Framework and ASP.MVC to use the connection string from app.config of another assembly 实体框架迁移无法在App.config文件中找到连接字符串 - Entity Framework Migration cant find connection string in App.config file 实体框架抛出无效操作异常 - 找不到app.config中的连接字符串 - Entity framework throwing invalid operation exception - Connection string in app.config not found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM