Old and new values are same in audit.net
See original GitHub issuethis is my controller
using (var audit = AuditScope.Create("Devices:AddDevices", () => model))
{
\\\
}
this is data provider
Audit.Core.Configuration.DataProvider = new AzureTableDataProvider()
{
ConnectionString = ConfigurationManager.ConnectionStrings["AuditDbConnection"].ToString(),
TableName = "tblbateventsauditing",
TableEntityMapper = ev => new AuditEventTableEntity(ev)
};
but oup put gives same Old and new values
"Target":{
"Type":"Devices",
"Old":{
"UserId":"",
"IvpId":0,
"UserName":"",
"DeviceCode":"XXXXX",
"PurchaseDate":"2018-09-09T00:00:00",
"PurchasePlaceId":12,
"Active":false,
"UpdatedDate":"0001-01-01T00:00:00",
"DeviceStatusId":0,
"DateofReplacement":"0001-01-01T00:00:00",
"DateofTransfer":"0001-01-01T00:00:00",
"RegistrationDate":"0001-01-01T00:00:00",
"TotalRecords":0,
"Id":18,
"CurrentStatusId":0,
"TRCCode":""
},
"New":{
"UserId":"",
"IvpId":0,
"UserName":"",
"DeviceCode":"XXXXXX",
"PurchaseDate":"2018-09-09T00:00:00",
"PurchasePlaceId":12,
"Active":false,
"UpdatedDate":"0001-01-01T00:00:00",
"DeviceStatusId":0,
"DateofReplacement":"0001-01-01T00:00:00",
"DateofTransfer":"0001-01-01T00:00:00",
"RegistrationDate":"0001-01-01T00:00:00",
"TotalRecords":0,
"Id":18,
"Createdby":"backoffice\\systemadmin",
"Updatedby":"backoffice\\systemadmin",
"CurrentStatusId":0,
"TRCCode":""
}
},
Can you please provide solution for this. @thepirat000
Thanks !
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
EF2.2 Core 2.2 Auditing returns same old and new value ...
I am trying to implement an Audit table in my .net core (2.2) using EF 2.2 code first. My intention is to log...
Read more >Audit Trail Implementation in ASP.NET Core with Entity ...
We will track the following with our implementation. TableName; Affected Column(s); Primary Key / Value of the Table; Old Values; New Values ......
Read more >Entity Framework Core: History / Audit table
The OnBeforeChanges method creates a list of AuditEntry . An AuditEntry store the table name, the ids and the old and new values...
Read more >Retrieve the history of audited data changes - Power Apps
Provides details when data changes occur for a record. Provides access to old values and new values. Returned by the following types of...
Read more >Audit.NET
An extensible framework to audit executing operations in .NET and .NET Core. Generate audit logs with evidence for reconstruction and examination of ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks a lot for this, it works like a charm!
Now the EventEntry.Changes contain the correct OriginalValue and NewValue.
Because the logic we’re using sets the state of the item to “EntityState.Modified” before saving, all columns are included in the Changes. This is not an Audit.NET issue, but is caused by our own code.
Since the addition of ReloadDatabaseValues, we can filter the audit data before writing it to the database. (AuditLog is our generic logging table)
Starting from version 21.0.2, the Audit.EntityFramework and Audit.EntityFramework.Core libraries introduce a new feature.
The setting called
ReloadDatabaseValues
can be globally or individually configured for a DbContext instance. It determines whether the original values of audited entities should be fetched from the database prior to saving the audit event.Consider the following examples of update and delete operations:
If the ReloadDatabaseValues is not set to true, the EF Change Tracker will lack knowledge of the original values.
Enabling the
ReloadDatabaseValues
setting triggers an extra database query to retrieve the original values prior to the update operation. As a result, the audit event will contain the original values.