How to use Audit.EntityFramework.Identity for .Net 6

575 Views Asked by At

Identity in .Net 6 using razor pages. I want to audit ASP.NET Identity entities using Audit.EntityFramework.Identity. But I don't see any document.

I changed my ApplicationDbContext.cs

public class ApplicationDbContext : AuditIdentityDbContext
{
    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        optionsBuilder.AddInterceptors(new AuditSaveChangesInterceptor());
    }
}

I don't see anything write to my Event table.

1

There are 1 best solutions below

0
On

I figure it out before I put:

Audit.EntityFramework.Configuration.Setup()
                .ForContext<SSAreaDbContext>(_ => _
                    .AuditEventType("EF:{context}"))
                .UseOptOut();

SSAreaDbContext not include ApplicationDbContext

Now:

Audit.EntityFramework.Configuration.Setup()
                .ForAnyContext(x => x.IncludeEntityObjects(true)
                .AuditEventType("{context}:{database}"))
                .UseOptOut();

Everything is working now.