我有一个C# / Entity Framework的Web应用程序,可以在本地SQL 2012数据库上正常运行。我将数据库复制到了一个新的RDS实例,并且可以通过Visual Studio和SQL Server Management Studio访问该数据库。
我有一个单元测试,该测试对用户进行身份验证,然后尝试使用Entity Framework调用在表中插入记录-- dataContext.SaveChanges()。
我收到以下错误:
{"The underlying provider failed on Open."}
{"No such host is known"}
{"A network-related or instance-specific error occurred while establishing a connection to SQL Server.
The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.
(provider: TCP Provider, error: 0 - No such host is known.)"}
我已经在网上搜索了一整天,但是到目前为止没有找到任何建议的方法来解决以下问题:
- 端口1433是开放的,我可以通过Telnet访问入口点
- 我的IP地址被默认安全组的CIDR / IP范围覆盖。
- 当我尝试打开数据上下文上的连接时,就会出现错误。
- 数据库服务器已配置为接受远程连接。
- 数据库服务器已配置为使用混合身份验证(包括Windows和SQL Server)。
Entity Framework连接字符串
connectionString = "metadata=res://*/MyDb.csdl|res://*/MyDb.ssdl|res://*/MyDb.msl;provider=System.Data.SqlClient;provider connection string="Data Source=MyAwsEntryPoint;Initial Catalog=MyDb;User ID=MyUser;Password=MyPassword;Persist Security Info=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient"
标准的数据库连接字符串
connectionString = "Data Source=MyAwsEntryPoint,1433;Initial Catalog=MyDb;User ID=MyUser;Password=MyPassword;Persist Security Info=True;Application Name=MyAppName;"