Website will only connect to local host database?

Oct 6 2018 3:40 PM
Hi
 
Hope someone can help me.
 
All of the sudden my MVC project won't start locally, or when it is deployed. It seems as though it is expecting the database på local and not in Azure as it is.
 
Looking in Web.config everything looks correct - defaultConnection points to my Azure SQL db, but when it starts I get the error below.
 
I cannot remember installing any new updates or references lately.
 
Can someone guide me in the right direction?
 
I've tried the following:
- added "<clear />" in web.config just before the connection string (resulted in different error)
- Looking for wrong imports in Startup.Auth.cs (found in another post)
 
I see a machine.config which has the wrong connection string, but unsure when that file is created, and from where it gets it's information.
 
 
  1. [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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)]  
  2.    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) +1370  
  3.    System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +679  
  4.    System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions) +57  
  5.    System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +1142  
  6.    System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +312  
  7.    System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) +126  
  8.    System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +255  
  9.    System.Data.SqlClient.SqlConnection.Open() +128  
  10.    System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trusted, String connectionString) +79  
  11.   
  12. [HttpException (0x80004005): Unable to connect to SQL Server database.]  
  13.    System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trusted, String connectionString) +169  
  14.    System.Web.Management.SqlServices.SetupApplicationServices(String server, String user, String password, Boolean trusted, String connectionString, String database, String dbFileName, SqlFeatures features, Boolean install) +118  
  15.    System.Web.Management.SqlServices.Install(String database, String dbFileName, String connectionString) +56  
  16.    System.Web.DataAccess.SqlConnectionHelper.CreateMdfFile(String fullFileName, String dataDir, String connectionString) +451 
 Thanks in advance

Answers (1)