Base solution for your next web application
Open Closed

EntityHistory on EF 6.x #7458


User avatar
0
andmattia created

Can you confirm that the History is enable only on .Net EF Core?

I check the compare map and I don't find anything about that?

Mattia


7 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    Please see here: https://aspnetboilerplate.com/Pages/Documents/Entity-History#entity-framework-6-x

  • User Avatar
    0
    andmattia created

    thk because on stackoverflow there was an old answer or probably old answer... Stackoverflow.

    So now I add on my core module this 2 lines

                Configuration.EntityHistory.IsEnabled = true;
                Configuration.EntityHistory.Selectors.Add("Activity", typeof(Activities.Activity));
    

    but no history works... I check on my db and I don't find any table named History? is it correct? Or maybe I lost some migration?

  • User Avatar
    0
    maliming created
    Support Team

    What is your abp version?

  • User Avatar
    0
    andmattia created

    Sorry I forget to write it: ABP / ABP Zerp 4.2.0

  • User Avatar
    0
    maliming created
    Support Team

    [Entity History Support for EF6] This feature requires abp version greater than or equal to 4.5.

    https://github.com/aspnetboilerplate/aspnetboilerplate/pull/4358

  • User Avatar
    0
    andmattia created

    Hi maliming

    I update my solution to 4.8.1 and now on my DB there are the History Log Tables. So I add the code like in the documenation to track my entity Activity a do an update but nothing will be tracked on DB

        [Audited]
        public class Activity : FullAuditedEntity<long>, IMustHaveTenant
        {
            public int TenantId { get; set; }
            public DateTime Date { get; set; }
            public DateTime IntTime { get; set; }
            ...
        }
    
    // On my PreInitialize module
        
        Configuration.EntityHistory.IsEnabled = true;
                Configuration.EntityHistory.Selectors.Add(new NamedTypeSelector(
                    "Abp.FullAuditedEntities",
                    type => typeof (IFullAudited).IsAssignableFrom(type)
                ));
    
    

    what I'm wrong?

  • User Avatar
    0
    andmattia created

    Sorry my mistake.

    My application is multidbcontext so on other dbcontext then the first I've used AbpDbContext that not has implemented the HistoryEntity. So I change my dbcontext to use AbpZeroDbContext so now history works well.