Efcore: Transform EF warnings into exceptions during debug

Created on 7 Feb 2019  路  1Comment  路  Source: dotnet/efcore

Hi,
yesterday I casually stumbled upon the log "Warning: The LINQ expression ... could not be translated and will be evaluated locally." The cause was a trivial where condition that I expected to be innocent and instead caused to retrieve a lot of rows and process locally [ .Where(el => el.UserId == userId && el.Date == new DateTime(dt.Year, dt.Month, 1)) - EF didn't like the "new" in the expression, using a temp variable to store the new DateTime fixed it.].
So I decided to check my code to look for other similar situations. Luckily I have a lot of tests an I just had to check the logs for the warning.

Question is:

Is is possible to change EF warnings into exceptions so that at debug/developing time those cases can be found out easily?

Thanks!

closed-question customer-reported

Most helpful comment

Yes, it's possible and is a good idea. Take a look at this doc page.

>All comments

Yes, it's possible and is a good idea. Take a look at this doc page.

Was this page helpful?
0 / 5 - 0 ratings