Skip to content

How to exclude tracked entities from audit? #506

Answered by thepirat000
kejdajar asked this question in Q&A
Discussion options

You must be logged in to vote

Can you share the code of your IRepository and also the relevant code on your DbContext?
Please also include the Dependency Injection relevant configuration.

Note you can set the AuditDisabled property to true on the AuditDbContext instance(s) used by your background job, but it will depend on how you create the DbContext instance on your repository.

Another option could be to define a specific DbContext class that inherits from your DbContext but bypasses the audits:

public class NoAuditDbContext : YourDbContext
{
    public NoAuditDbContext(DbContextOptions options) : base(options) { }
    
    public override int SaveChanges() => ((IAuditBypass)this).SaveChangesBypassAudit();
    
    p…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by kejdajar
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants