Set Command Timeout in EF 6

30,014

Check this :

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;
Share:
30,014

Related videos on Youtube

Ali
Author by

Ali

Ali Rizvi Developer @ Agoda

Updated on February 15, 2020

Comments

  • Ali
    Ali about 4 years

    I want to set command timeout for query execution, currently I am doing context.Database.CommandTimeout = 90; but i feel this is not working, I tried checking the process logs in database but found the time difference was always less than 90sec.

    Can someone help how can I set the database timeout in Entity Framework 6?

  • Zeek2
    Zeek2 about 3 years
    Thanks. That fixed many occurrences of this build error for me: Upgrading from Entity Framework 5 to EF6 Error BC30456 "'CommandTimeout' is not a member of"
  • T M
    T M almost 3 years
    For EF 6.2 at least this needs to be placed in Configuration class in the migrations folder in the constructor: public Configuration(){ CommandTimeout = 3600; }