In my code, I used loading the linked object using await FindAsync , hoping that I better comply with the async C # instructions.
var activeTemplate = await exec.DbContext .FormTemplates.FindAsync(exec.Form.ActiveTemplateId);
and it worked slowly, was slow in the sql server profiler, the query text was fast in SSMS. It took 5 seconds to get this line.
Alternative:
var activeTemplate = exec.Form.ActiveTemplate;
much faster. By all means, the problem, apparently, is not a parameterization, since the number of reads in fast and slow queries is the same.
One possible irrelevant point is that the extracted object contains a row property containing ~ 1 MB of text. An asp.net mvc application running on the same machine as the sql server using (local).
What is the reason for the observed slowness?
EDIT: after @ jbl's comment, I did a few more experiments:
var activeTemplate = await exec.DbContext.FormTemplates .FirstOrDefaultAsync(x => x.Id == exec.Form.ActiveTemplateId);
source share