Last post Mar 17, 2015 07:40 AM by Kevin Shen - MSFT
Mar 13, 2015 08:17 AM|yogendrakmishra|LINK
i am using below code for checking connection
and my connection string is as below :
Data Source=******;Initial Catalog=*******;User ID=sa;Password=*******;MultipleActiveResultSets=true;Connection Timeout=30
Now if connection string is wrong at that time it takes 60 sec (double of the provided time) to identify whether connection is exist or not(if i give
Connection Timeout=120 than it will take 240 sec to identify). but in my connection string i have mention connection timeout = 30
Mar 13, 2015 08:24 AM|PatriceSc|LINK
EF 6 or later? If I remember you have a connection resiliency feature so maybe could it be that EF actually tries twice before giving up?
Also stricly speaking it tests if the db exists (ie the connection could succeed and it could return false) rather than that the "connexion exists".
Mar 13, 2015 08:51 AM|yogendrakmishra|LINK
I have checked my code and i am not using any connection resiliency feature in it. it might take the default settings of EF6.
Is there anything to stop EF6 from retrying the connection check.
Mar 13, 2015 09:22 AM|itpreneur|LINK
Try to put in your DbContext initialization.
I believe there is a still a known bug for EF5 and EF6 with regards to connection timeout.
DbContext.Database.CommandTimeout = 30;
Mar 17, 2015 07:40 AM|Kevin Shen - MSFT|LINK
Thanks for your post here.
Connection retry is taken care of by an implementation of the IDbExecutionStrategy interface. Implementations of the IDbExecutionStrategy will be responsible for accepting an operation and, if an exception occurs, determining if a retry is appropriate
and retrying if it is. There are four execution strategies that ship with EF:
I suggest that you could refer to the link for more detailed information: