Entity Framework - what is the current command timeout value

前端 未结 5 1878
南方客
南方客 2021-01-17 07:49

I\'m using Entity Framework 5 and I wish to know the command timeout value.

In order to do so, I cast the dbContext object to an ObjectContext

5条回答
  •  一个人的身影
    2021-01-17 08:04

    From MSDN,

    • CommandTimeout property gets or sets the timeout value, in seconds, for all object context operations.
    • A null value indicates that the default value of the underlying provider will be used.

    So, if you are not setting it explicitly through code or passing it in your connection string (in MySQL) , then it is the default value of your provider.

    If you want to see a non-null value for CommandTimeout, then you will need to pass it in connectionString or set it through code.

    Who is the underlying provider?

    Underlying provider is the one you are passing in your connectionstring as providerName

    
      
      
    
    

    Here, System.Data.ProviderName is your underlying provider.

    If you are using MySql or MS Sql, According to the MySql Documentation and MSDN,

    • The default value is 30 secs.
    • A value of 0 indicates an indefinite wait and should be avoided.

      Note :

    The default command timeout can be changed using the connectionstring attribute Default Command Timeout in case of MySQL database providers.

提交回复
热议问题