Search code examples
c#asp.net-mvc-5entity-framework-6aspnetboilerplate

Can Entity History be enabled for ABP template?


I downloaded ABP template from website:

  • ABP v3.6.2
  • MVC5
  • MPA

I read how to enable Entity History and did these steps:

  1. in AppNameCoreModule.cs PreInitialize() method, I add:
// Entity History
Configuration.EntityHistory.IsEnabled = true;
Configuration.EntityHistory.IsEnabledForAnonymousUsers = false;
Configuration.EntityHistory.Selectors.Add(
    new NamedTypeSelector(
        "Abp.FullAuditedEntities",
        type => typeof(IFullAudited).IsAssignableFrom(type)
    )
);
  1. in AppNameDbContext.cs, I add:
// Entity History tables
public virtual DbSet<EntityChange> EntityChanges { get; set; }
public virtual DbSet<EntityChangeSet> EntityChangeSets { get; set; }
public virtual DbSet<EntityPropertyChange> EntityPropertyChanges { get; set; }

But the Entity History didn't work. Is there something wrong in my steps? And how to fix it?


Solution

  • Entity Framework 6x doesn't support Entity History. As far as I see you are adding the tables to your DbContext and you don't get exception. so you might be using MVC5 which has no Entity History support.