Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. The statement has been terminated

后端 未结 20 2224
臣服心动
臣服心动 2020-11-22 10:23

I have many users on my web site (20000-60000 per day), which is a download site for mobile files. I have remote access to my server (windows server 2008-R2).
I\'ve

20条回答
  •  -上瘾入骨i
    2020-11-22 10:40

    You have to set CommandTimeout attribute. You can set the CommandTimeout attribute in DbContext child class.

    public partial class StudentDatabaseEntities : DbContext
    {
        public StudentDatabaseEntities()
            : base("name=StudentDatabaseEntities")
        {
            this.Database.CommandTimeout = 180;
        }
    
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            throw new UnintentionalCodeFirstException();
        }
    
        public virtual DbSet StudentDbTables { get; set; }
    }
    

提交回复
热议问题