Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Entity change history in 5.1.0 #4639


User avatar
0
BobIngham created

.Net Core, Angular v5.1.0 I love the idea of the new Entity change history functionality offered in 5.1.0 and wanted to test before upgrading my current project. I download and create a new project. I add a new entity using the new RAD tool - GREAT JOB GUYS - and disable the Add migration and Update database options so I can carry out some final modifications before migrating to the database::

[Table("NcPerson")]
[Audited]
public class Person : FullAuditedEntity<Guid>, IMustHaveTenant, IMayHaveOrganizationUnit, IExtendableObject
{
    public int TenantId { get; set; }

    public long? OrganizationUnitId { get; set; }

    [Required]
    [StringLength(PersonConsts.MaxSalutationLength, MinimumLength = PersonConsts.MinSalutationLength)]
    public virtual string Salutation { get; set; }

    public string ExtensionData { get; set; }
}

I then migrate to the database. I modify my CoreModule.PreInitialize() method with the following lines:

Configuration.EntityHistory.IsEnabled = true;

Configuration.EntityHistory.Selectors.Add(
    new NamedTypeSelector(
    "Abp.FullAuditedEntities",
    type => typeof(IFullAudited).IsAssignableFrom(type)
));

I compile and run the project successfully. I add several people and update and delete one person. I have no data in my AbpEntityChangeSets table or associated tables. I started without the [Audited] attribute on my entity and without the line Configuration.EntityHistory.IsEnabled = true; (both of which should be unnecessary according to the documentation at [https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/doc/WebSite/Entity-History.md]). What am I doing wrong?


8 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team
  • User Avatar
    0
    vladsd created

    I installed RAD tool but cannot find any info on how to use it? Can you please direct me? Thanks.

  • User Avatar
    0
    aaron created
    Support Team

    @vladsd You can read the development guide here: https://aspnetzero.com/Documents/Development-Guide-Rad-Tool

  • User Avatar
    0
    vladsd created

    Thanks, got it, consider adding a link to documents page.

  • User Avatar
    0
    vladsd created

    I get an error.. <a class="postlink" href="https://gyazo.com/5ece69f3b2a1df9c719b05ee0758a40e">https://gyazo.com/5ece69f3b2a1df9c719b05ee0758a40e</a> I do have 5.0.6 project, so I need to copy some config files?

  • User Avatar
    0
    BobIngham created

    @Aaron, another one of life's little mysteries solved, once again I am in debt to your expertise. An excellent piece of code, well done!!!! This alone is worth the upgrade to 5.1.0, I will wait with baited breath for the user interface... Thank you again for your help.

  • User Avatar
    0
    vladsd created

    Once I copy AspNetZeroRadTool folder into project the tool is working

  • User Avatar
    0
    aaron created
    Support Team

    @BobIngham :)