27

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?

1

1 Answer 1

67

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;
Sign up to request clarification or add additional context in comments.

2 Comments

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"
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; }

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.