Background:
I've created a .Net Core (2.2.0) application using EFCore (2.2.2). Up until now I have been using a local SQL Server instance and am attempting to use an Azure SQL Server instead.
I have updated the connection string in the database context to that found on the Azure dashboard.
I have signed in to the account used in Azure within the SQL Server Object Explorer in VS2017, and the database is appearing.
I'm using a code-first approach so there are no tables available, until after running the application.
Error:
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: 25 - Connection string is not valid)
The connection string is:
.UseSqlServer(
@"Server = tcp:db.database.windows.net, 1433;
Initial Catalog = DB;
Persist Security Info = False;
User ID = [email protected];
Password = password;
MultipleActiveResultSets = False; Encrypt = True;
TrustServerCertificate = false;
Connection Timeout = 60;");
My local network hasn't got fantastic capabilities. Could this have an effect on connecting?
Or is there an error in this connection string?
Edit: I changed the connection timeout to 800 seconds, after a period of ~800 seconds the connection timed out again, this time with a slightly different error:
Error 2:
A network-related or '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.)'
Server=db.database.windows.net:1433;
? Or actually, you can leave the port off as well, since 1433 is the default. TCP is also the default. That's what all HTTP communication uses. – Chris Pratt