C# 使用实体框架访问远程数据库

C# 使用实体框架访问远程数据库,c#,entity-framework,C#,Entity Framework,我需要能够使用EF访问远程服务器上的数据库。我在app.config中有到远程数据库的连接字符串 当我尝试这个: using (var ctx = new PinnReportEntities("name=remoteConnection")) { . . . } 我明白了: The specified named connection is either not found in the configuration, not intended to be used w

我需要能够使用EF访问远程服务器上的数据库。我在app.config中有到远程数据库的连接字符串

当我尝试这个:

using (var ctx = new PinnReportEntities("name=remoteConnection"))
{
    .
    .
    .
}
我明白了:

The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.
命名连接在配置中并且有效,因此问题必须与EntityClient提供程序有关


我想做的是可能的吗?这是正确的方法吗?

如果您的启动项目与具有实体框架模型的项目不同,那么您必须在同一项目中创建配置文件才能工作。您的连接字符串是如何定义的?您的EF使用的是.edmx文件还是先编码?既然你提到app.config,你就不是在说web应用,对吧?ef模型是否在一个单独的程序集中?是否可以发布连接字符串(减少任何敏感位)