How to output file name and line number of Entity Framework queries during debugging or logging

In Entity Framework Core the TagWith feature is useful as it allows us to add arbitrary messages which will get outputted along with queries if we have query logging enabled.

And from Entity Framework Core 6 preview 6 there is a new TagWith overload which will automatically include the filename and the line number along with the query.

A simple example is below…

Leave a Reply

Your email address will not be published. Required fields are marked *