I am using the following LINQ query using EF Core and getting the following error:
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
Not sure what I am doing wrong here.
ECUserId
is a varchar
column and there is no index set on this table for this column.
Also checked the collation and it is set to 'SQL_Latin1_General_CP1_CI_AS' which is case sensitive.
string ECUserId = "TN504060"
var userStandby = await _context.UserStandby
.Where(standBy => ECUserId.Equals(standBy.ECUserId,
StringComparison.OrdinalIgnoreCase))
.FirstOrDefaultAsync();
The userStandby
table has got around 126580 records.
Can anyone help me fix the above timeout error?
Created an index on this column but still getting the same timeout error:
GO
CREATE NONCLUSTERED INDEX [IX_UserStandby_ECUserId]
ON [dbo].[UserStandby]([ECUserId] ASC);
The LINQ query is not generating the SQL query with the where
condition. What am I doing wrong here please?
Thanks.