0

I have just implemented the DuendeIdentity Server and by DBContext looks like this.

public class DataContext : ApiAuthorizationDbContext<ApplicationUser>
{
    public DataContext(
        DbContextOptions options,
        IOptions<OperationalStoreOptions> operationalStoreOptions) : base(options, operationalStoreOptions)
    {
    }
 ...

I now wish to implement some basic Database Auditing which I have successfully done in the past using this https://codewithmukesh.com/blog/audit-trail-implementation-in-aspnet-core/ however it is implemented in this way

public abstract class AuditableIdentityContext : IdentityDbContext
{
    public AuditableIdentityContext(DbContextOptions options) : base(options)
    {
    } 

With the DataContext then inheriting from it like

public partial class DataContext : AuditContext
{
    public DataContext(DbContextOptions<DataContext> options)
        : base(options)
    {
    }

I am trying to understand how I may use the two together. Any help would be appreciated.

Tim Cadieux
  • 447
  • 9
  • 21

1 Answers1

0

C# doesn't have multiple inheritance.

Consider using your ApiAuthorizationDbContext separately from your application-specific DbContext. You can still use a DbSet<ApplicationUser> to reference your users from your application entities.

CodeCaster
  • 147,647
  • 23
  • 218
  • 272
  • I'm not the backend guy, he's off sick so I don't really understand how to de-couple. Would you have an example you could point to plz? – Tim Cadieux Aug 15 '22 at 13:09