Entity Framework “Invalid attempt to read when no data is present” with 'large' data on Azure

时光怂恿深爱的人放手 提交于 2019-12-04 04:20:38

Increase the CommandTimeout on the context.

I increased the command timeout, and it worked.

using (var db = new DBEntities()) 
{ 
//setting the CommandTimeout before the .ToList()
db.CommandTimeout = 120;

var users = (from u in db.Users 
             where u.PK == userid 
             select u).ToList();

if (users.Any()) 
{ 
    var selectedUser = users.Single(); 
    if (selectedUser.Password.Equals(passwordHash)) 
    { 
        // ****************************** 
        // * error is on the next line! * 
        // ****************************** 
        var settings = (from s in db.Settings 
                        where s.User == selectedUser.PK 
                        select s).ToList(); 
    } 
} 
}   
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!