4
votes

I have a console application that has Amazon rds connection with Entity Framework . It is running well in my local PC. But When I am running my application in Amazon EC2 It can not connect to my Amazon RDS database and saying 'The underlying provider failed on open' . My connection string of entity framework is ...

<add name="MyEntities" connectionString="metadata=res://*/YhFinModel.csdl|res://*/YhFinModel.ssdl|res://*/YhFinModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=datasourcename,portnumber;initial catalog=databasename;persist security info=True;user id=userid;password=password;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

Thanks in advance.

3

3 Answers

12
votes

Have you looked at your security groups? I think you will need to add the EC2 security group you are using to have port access to your RDS instance.

3
votes

If you have your EC2 instance and RDS instance in different regions you will have to go to RDS Security Group and enter the external IP of the EC2 instance as CIDR/IP. At least that's what worked for me.

0
votes

This is a slightly newer version that was required to get this to work. Click RDS Dashboard. Select your RDS Instance->Click on Details Icon->Click on Security Groups URL that is attached the selected RDS instance. This will place you into Security Group Settings of EC2. Once you select your Security Group, click on Inbound tab. Here you need to possible modify or Create a new rule (MS SQL, TCP, Port (eg 1433), and then an IP Address/IP Address Range of allowable requests. You could set all IP Addresses to confirm it works, and then tighten up the security to IP Address range based on instances, and/or testing environment IP Address.

good luck.