Set database timeout in Entity Framework

后端 未结 9 1774
囚心锁ツ
囚心锁ツ 2020-11-29 16:42

My command keeps timing out, so I need to change the default command timeout value.

I\'ve found myDb.Database.Connection.ConnectionTimeout, but it\'s

9条回答
  •  迷失自我
    2020-11-29 17:43

    In the generated constructor code it should call OnContextCreated()

    I added this partial class to solve the problem:

    partial class MyContext: ObjectContext
    {
        partial void OnContextCreated()
        {
            this.CommandTimeout = 300;
        }
    }
    

提交回复
热议问题