Error When Trying to Update RDS Database in ASP.NET Visual Studio Environment

0

So I've been struggling with this issue for a while. When I run Update-Database in Package Manager Console, I get the following output.

System.Data.SqlClient.SqlException (0x80131904): 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) ---> System.ComponentModel.Win32Exception (0x80004005): The network path was not found
   at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   ... more errors ...
   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run()
ClientConnectionId:00000000-0000-0000-0000-000000000000
Error Number:53,State:0,Class:20
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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

I have verified that I am able to connect to my RDS Database in SQL Server Management Studio, and I can also open it within Server Explorer in Visual Studio itself. I am able to run Enable-Migrations with no issue as well. Below are my connection strings and where I initialize the DBContext. The connection string is the one provided when I connect to my DB in Visual Studio.

web.config

<connectionStrings>
    <add name="dbname" connectionString="Data Source=dbname.xxxxxxxxxxxx.us-east-2.rds.amazonaws.com;Initial Catalog=dbname;User ID=username;Password=password;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False" providerName="System.Data.SqlClient" />
</connectionStrings>
<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
</entityFramework>

Context.cs

public class ApplicationContext : DbContext
{
    public DbSet<Team> Teams {get; set;}
}

I had done a similar project before, but I did not face much issue with the connection string automatically adjusting to my database. I do believe I have adjusted the security groups for my RDS instance to enable public accessibility and given all security groups access.

Any help would be appreciated, and if more information is needed I will gladly provide it. I am also able to build and run the project perfectly fine.

c#
sql
asp.net
entity-framework
amazon-rds
asked on Stack Overflow Oct 20, 2018 by Colin Legge

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0