We are developing a custom WebApp and we are getting a error with Entity Framwork.
We are have a code-first Entity Framework 6.1.3 context that throws an SQL timeout exception when directly querying a certain table using SQL Server 2014. 
Query code: 
var q = _appContext.PJLABDET 
.Where(x => x.user1.Trim() == ServiceCallID.Trim() && x.user3 == LineID); 
returnObject = q.SingleOrDefault(); 
The query works and returns instantly when querying a copy of the same database on SQL Server 2012. Also, extracting the raw SQL query from the LINQ and executing manually also returns instantly. 
The query works on 2014 when I precede it with an explicit open command: 
_appContext.Database.Connection.Open(); 
var q = _appContext.PJLABDET 
.Where(x => x.user1.Trim() == ServiceCallID.Trim() && x.user3 == LineID); 
returnObject = q.SingleOrDefault(); 
This leads me to believe that for some reason, EF6 isn't opening connections to our SQL 2014 server properly. Also, this only happens with this one table, any other queries seem to be working just fine. 
Any ideas? We're trying to avoid rebuilding our SQL 2014 server.
*This post is locked for comments
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156