Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Entity framework AWS RDS卷的EF5动态连接字符串_Entity Framework_Amazon Ec2_Rds - Fatal编程技术网

Entity framework AWS RDS卷的EF5动态连接字符串

Entity framework AWS RDS卷的EF5动态连接字符串,entity-framework,amazon-ec2,rds,Entity Framework,Amazon Ec2,Rds,我正在尝试为我的POCO EF5 Web应用程序创建动态连接字符串,但遇到了一些问题 public class AppDbContext : DbContext { public AppDbContext() : this(EFBuilder.SqlConnection) { } public AppDbContext(string connectionString) : base(connectionString) {

我正在尝试为我的POCO EF5 Web应用程序创建动态连接字符串,但遇到了一些问题

public class AppDbContext : DbContext
{
    public AppDbContext()
        : this(EFBuilder.SqlConnection)
    {
    }

    public AppDbContext(string connectionString) : base(connectionString)
    {
        Database.DefaultConnectionFactory = new SqlConnectionFactory(connectionString); 
        //OR: Database.Connection.ConnectionString = connectionString
    }
}
EFBuilder.SqlConnection
is
Data Source=addresstomedb.us-east-1.rds.amazonaws.com,1433;持久安全信息=True;初始目录=Name.DB;用户ID=hello;密码=世界

数据库是RDS卷,安全组配置正确,可以访问。我知道连接字符串是有效的,因为我没有动态调用它,而是将它添加到
Web.config
中,它工作正常,但由于某些原因,当动态访问时,我遇到了连接问题。有人知道这里少了什么吗

这是一个错误,通常在关闭端口时是一个一般性错误,但是当我手动复制到web.config时,它正在工作,所以不可能是这样

建立与SQL Server的连接时发生与网络相关或特定于实例的错误。找不到服务器或无法访问服务器。验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。(提供程序:SQL网络接口,错误:26-定位指定的服务器/实例时出错)


如果您硬编码连接字符串而不是传递
EFBuilder.SqlConnection
,是否有效?:(-看看这篇文章。希望它能帮助您解决问题: