Feature like query tags but when calling SaveChanges
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 30/100
Research direction
Start by tracing the existing TagWith behavior and the SaveChanges update-command path in EF Core, then compare the SQL generated for tagged queries with SQL generated during SaveChanges against SQL Server. Define the supported tagging behavior and verify it with focused coverage for update commands.
Written by the indexing model from the issue text.
Description
I just setup a basic extension method that adds the calling file's path & line number as a tag to the given query:
public static class IQueryableTagExtensions
{
public static IQueryable<T> TagWithFileInfo<T>(this IQueryable<T> source, [CallerFilePath] string fromFile = null, [CallerLineNumber] int onLine = 0, string comment = null)
{
var tagMessage = fromFile + "@" + onLine + (string.IsNullOrEmpty(comment) ? "" : " - " + comment);
return source.TagWith(tagMessage);
}
}
This works fine when querying for data, but I'd also like it to be part of the queries that execute when calling db.SaveChanges(). Is this possible currently? Adding query tags to updates is just as important, if not more important with this one, than adding them to selects.
The inspiration for this came from Stack Overflow who prepends this info to every query that runs through Dapper https://gist.github.com/NickCraver/c6f371bf8df37e05c4f09fd3c02ef6a2
What I really like about this is when using MiniProfiler this info becomes available making debugging easier. Then taken a step further it's included in Sentry's breadcrumbs that are part of logged exceptions, and it's also passed into App Insights. Both of those scenarios make production issues easier to track down.
Further technical details
EF Core version: 2.2.0
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Win10
IDE: Visual Studio 2017 15.9.3
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 134
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/efcore
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
-
customer-reported
Difficulty 5/5 Over a week Newbie friendliness 38/100
-
area-cosmos area-vector-search
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
area-cosmos
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
area-tools needs-design
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15108 · 1 comment ·
-
area/docs-content Bug pulumi/docs
Difficulty 1/5 1-3 hours Newbie friendliness 94/100
-
agentic-workflows untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 76/100