Entity Framework query never returns

entity-framework entity-framework-6 sql-server

Question

I have a very simple EF query below that never returns. The call to Any() just hangs.

if (!_context.SalesRoundRobinAssignments.Any()) return salesPeopleIds.First();

When I look at the sql profiler I don't see that query being executed however I do see the following.

SQL: BatchStarting  select serverproperty('EngineEdition')
SQL: BatchCompleted select serverproperty('EngineEdition')

I've also tried adding this before the query but nothing gets written to the output window aside from the same serverproperty query shown above.

_context.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);

Any ideas what else I can look at to figure out what's going on?

1
0
10/7/2019 1:00:37 PM

Popular Answer

Did you check the connection string from your web.config/app.config that your Entity Framework Context uses to connect with the database? The query can be executing in another database and that's why you don't see nothing with the SQL profile.

Try to debug and see in execution time, which connection string your application is passing to string connectionString parameter:


 public YourDBContext(string connectionString): base(connectionString)
 {
 }

0
10/7/2019 6:11:35 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow