I was looking at my logs recently, and I noticed that one of my queries was causing a warning that said "The LINQ expression '{expression}' could not be translated and will be evaluated locally." This is because of a mistake that I made in my query expression.
I was able to fix this issue without too much trouble. My question is: How can I detect this situation in the future without manually looking at the logs?
Two possible solutions (neither of which I know how to implement):
My goal is to be able to prevent a mistake like this from accidentally slipping into production.
Using the link provided by @GertArnold, I was able to convert the warning into an error using the following code:
services.AddDbContext<MyContext>(
options =>
{
options.UseSqlServer("connection-string");
options.ConfigureWarnings(warnings => warnings.Throw(RelationalEventId.QueryClientEvaluationWarning));
}
)