This project is read-only.

Here’s a quick guide to getting started with AuditDbContext.

  • Add a reference to AuditDbContext in you project.
  • Derive you entities from AuditableEntity, or implement the IAuditable interface.
        public class Customer : AuditableEntity
            public virtual int CustomerId { get; protected set; }
            public virtual string CustomerName { get; set; }
  • Derive you audit entities from AuditEntity, or implement the IAudit interface.
        public class CustomerAudit : AuditEntity
            public virtual int CustomerAuditId { get; protected set; }
            public virtual int CustomerId { get; private set; }
            public virtual string CustomerName { get; set; }
  • Derive your data context from AuditDbContext instead of DbContext.
        public class Context : AuditDbContext
            public IDbSet<Customer> Customers { get; set; }
            public IDbSet<CustomerAudit> CustomerAudits { get; set; }
            public Context(string conn)
                : base(conn)
  • Either:
    • Add each of you auditable classes with their audit entity to the config file.
          <section name="entityFramework.Audit" type="EntityFramework.Auditing.AuditConfigurationSection, EntityFramework.Auditing" />
              <add name="EntityFramework.Auditing.Test.Customer, EntityFramework.Auditing.Test" audit="EntityFramework.Auditing.Test.CustomerAudit, EntityFramework.Auditing.Test" />
    • Or register the audit entities in code using the AuditDbContext.RegisterAuditType method.
      AuditDbContext.RegisterAuditType(typeof(Customer), typeof(CustomerAudit));

Last edited Mar 28, 2012 at 7:33 AM by russ256, version 12


azizbouyahyaoui Nov 25, 2012 at 10:39 AM 
How can i use it in a MVC project?