Skip to main content

Notifications

Microsoft Dynamics SL (Archived)

Dynamics 2015 - WebApp

Posted on by 635

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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans