EF Core SqlServer connect hang
See original GitHub issueDescribe the bug
Can not able to connect SQL Server instance. No exceptions, it just hangs at ‘OpenConnection’ function indefinitely. Even though I give 10 seconds of timeout, it does not timeout.
No exceptions. Just logs. Trace enabled.
May 13 09:08:46 ubuntu pompa-proxy[4071]: dbug: Microsoft.EntityFrameworkCore.Infrastructure[10401]
May 13 09:08:46 ubuntu pompa-proxy[4071]: An 'IServiceProvider' was created for internal use by Entity Framework.
May 13 09:08:52 ubuntu pompa-proxy[4071]: info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
May 13 09:08:52 ubuntu pompa-proxy[4071]: Entity Framework Core 3.1.4 initialized 'OrkaContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: CommandTimeout=10
May 13 09:08:52 ubuntu pompa-proxy[4071]: dbug: Microsoft.EntityFrameworkCore.Database.Connection[20000]
May 13 09:08:52 ubuntu pompa-proxy[4071]: Opening connection to database 'ORKA_0996_2020' on server '192.168.0.250\ORKASQL'.
To reproduce
var context = _serviceLocator.GetInstance<OrkaContext>();
context.Database.OpenConnection();
_logger.LogInformation("Execution is starting...");
context.Database.ExecuteSqlRaw(@"...
Expected behavior
A connection should be opened or an exception should be thrown.
Further technical details
Microsoft.Data.SqlClient version: 3.1.4 .NET target: .NET Core 3.1.4 SQL Server version: SQL Server 2012 SP4 Operating system: Ubuntu 20.04 (Client) , Windows Server 2012 (Server)
Additional context It was working until I have upgraded my ubuntu. At first, I got an SSL exception. I have upgraded the SQL server to SP4 to resolve issue, it did solve problem. but hang problem started.
I can connect to the database from the server’s itself by sql server management studio using sql server authentication. There are windows computers in the office, I can confirm they can connect to the sql server, too.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)

Top Related StackOverflow Question
I have resolved my issue by setting
MinProtocol = TLSv1.1at openssl.cnf. BTWMinProtocol = TLSv1.0did not work, that was the main reason I have struggled with this issue for hours.But I think infinite hang should be solved. It is up to you.
Could you also check if server certificate is not encrypted with SHA1? Related issue was also reported here: https://github.com/dotnet/SqlClient/issues/538#issuecomment-622587024