question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change MaxValueLenght for NewValue and OriginalValue properties in EntityPropertyChange

See original GitHub issue

Hi, i have problem with NewValue and OriginalValue related with this closed issue: https://github.com/aspnetboilerplate/aspnetboilerplate/issues/4203

like as @mwj033 mentioned in above issue, OnModelCreating did not any effect. @ryancyq sugestion is not enough to solve this problem. Yes, in database NewValue column was changed to character varying (1024 * 6), but when repository insert property change ORM entity, NewValue is truncated to 512 chars. I was tried to replace DbSet using new keyword and change EntityHistory objects

        public new DbSet<TopEntityChange> EntityChanges { get; set; }
        public new DbSet<TopEntityPropertyChange> EntityPropertyChanges { get; set; }

where NewValue and OriginalValue are overrided

    [Table("AbpEntityPropertyChanges")]
    public class TopEntityPropertyChange: EntityPropertyChange
    {
        public override string NewValue { get; set; }
        public override string OriginalValue { get; set; }

        public new const int MaxValueLength = 1024 * 6;
    }

but did not help. Have you any idea how to increase number of chars for NewValue and OriginalValue ?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ruzanowskicommented, Jan 26, 2023

Yes! Correct!

Remaining steps:

  1. Import Nuget Abp.ZeroCore.EntityFrameworkCore
  2. Copy https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.ZeroCore.EntityFrameworkCore/EntityHistory/EntityHistoryHelper.cs
  3. Copy https://github.com/aspnetboilerplate/aspnetboilerplate/blob/0fcb1bc10dd8d78e0e2b5fd87ca14c897b399c77/src/Abp.ZeroCore.EntityFrameworkCore/EntityHistory/Extensions/EntityEntryExtensions.cs#L15
  4. Copy https://github.com/aspnetboilerplate/aspnetboilerplate/blob/0fcb1bc10dd8d78e0e2b5fd87ca14c897b399c77/src/Abp.ZeroCore.EntityFrameworkCore/EntityHistory/Extensions/PropertyEntryExtensions.cs#L8
  5. Change your EntityHistoryHelper and its method CreateEntityPropertyChange. Apply a new extended model instead of EntityPropertyChange (I changed to FullEntityPropertyChange).
  6. Don’t forget about: Configuration.ReplaceService<IEntityHistoryHelper, MyEntityHistoryHelper>(DependencyLifeStyle.Transient);

Thanks @ismcagdas it works 👍

1reaction
1jedrzej1commented, Jan 4, 2023

@ismcagdas thank you very much. I will check wheteher your tip working.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I change MaxValueLength of NewValue and ...
I am using aspnetzero and I have enabled entity history. Maxvaluelength of NewValue and OriginalValue is 512 chars in ...
Read more >
Increase size of EntityPropertyChange.NewValue ...
Is it possible to change 'EntityPropertyChange.MaxValueLength' to a static variable, just like in auditlog?
Read more >
EntityHistory Property change value equality check with ...
OriginalValue == propertyChange.NewValue The equality check for OrignalValue and NewValue is inaccurate when the values are large ...
Read more >
AuditLog remove MaxLength constraint on OriginalValue and ...
In the Constructor (shown in codeblock below) of the EntityPropertyChange it truncates the value based upon MaxNewValueLength and ...
Read more >
C# (CSharp) EntityEntry.Property Examples
OriginalValue.ToJsonString().TruncateWithPostfix(EntityPropertyChange.MaxValueLength), PropertyName = property.Name, PropertyTypeFullName = property.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found