You must Sign In to post a response.
  • Category: .NET

    System.Data.Entity.Core.EntityCommandExecutionException

    Hi All,

    I was randomly getting following exception in my web application. Even i have specified connection Timeout in my web.config. Please share your suggestions

    Error Message : An error occurred while executing the command definition. See the inner exception for details.
    Inner Exception : Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
    Exception Type : System.Data.Entity.Core.EntityCommandExecutionException

    Thanks,
    Simiyon A
  • #767105
    try removing timeout value from the connection string and set it on the data context object itself. This will work if you remove the conflicting value from the connection string.

    Entity Framework 6:
    this.context.Database.CommandTimeout = 180;

    Entity Framework 5:
    ((IObjectContextAdapter)this.context).ObjectContext.CommandTimeout = 180;

    Entity Framework 4 and below:
    this.context.CommandTimeout = 180;

  • #767106
    Hi,

    As per error details your execution time crosses the limit which you define, so that only you got this error. What's the time you are given in connection string and check whether your Entity Query execution time limit, if it's more than the time limit which you given then you need to increase the time for particular execution, call the below line of code in front of your execution query.


    this.context.Database.CommandTimeout = 90;

    // your execution query


    Default timeout is 30 secs, in above scenario I set it for 90 secs. If you still face the problem then let us know.

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #767112
    Timeout expired are of following types,
    1. Query timeout
    2. Execution time out
    3. Session timeout

    1. Query timeout
    It is the time taken by SQL/database for processing query, it is related to database activities
    2. Execution timeout
    The ExecutionTimeout property indicates the maximum number of seconds a request is allowed to execute before being automatically shut down by ASP.NET. The default is 110 seconds. This time-out applies only if the debug attribute in the element is set to false
    3. Session Timeout
    The Timeout property specifies the time-out period assigned to the Session object for the application, in minutes. If the user does not refresh or request a page within the time-out period, the session ends.

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]


Sign In to post your comments