0

We noticed that when we do F10 debugging and we spend time analyzing values of variables suddenly when we step on statement which queries something in the database through entity framework we get an error about connection being closed.

This only happens when debugging and not when running application. Also it only happens when we spend substantial time analyzing variables and not when quickly doing F10 presses.

This happens on multiple computers.

1 Answer 1

1

This is because the default command timeout is 30 seconds.

You can set the command timeout for a context. In the constructor of your DbContext subclass add this code:

#if DEBUG
    this.Database.CommandTimeout = 300;
#endif

This will give you 300 seconds to keep an active command open.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.