How To Track Entity Changes With EF Core | Audit Logging

How To Track Entity Changes With EF Core | Audit Logging

Milan Jovanović

1 год назад

23,981 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Anonim
Anonim - 07.10.2023 23:21

How would you update in this approach if the interface has a user update field?

Ответить
Tech Family
Tech Family - 21.09.2023 11:39

Good video, many thanks

Ответить
Gerard Uab
Gerard Uab - 19.09.2023 23:35

Can the interceptor have a Principal in orher to obtain curren claims of user?

Ответить
Farhad Mirshekar
Farhad Mirshekar - 05.09.2023 21:24

Great thanks a lot

Ответить
Joao Roberto
Joao Roberto - 04.09.2023 06:41

Sorry I couldnt get how you saved this audit in database, if you saved for exemple “old values” and “new values”

Ответить
Android Savior
Android Savior - 07.08.2023 00:37

Did you share the full code of this project ? I want to learn clean arc. From it

Ответить
JMVD_uy
JMVD_uy - 04.08.2023 16:17

Hi Milan, something I'd like to understand is where would that information (CreatedOnUtc, ModifiedOnUtic) be stored. Would it be stored on a separate table in the database?

Ответить
Faizal Balsania
Faizal Balsania - 24.03.2023 22:35

VS theme please?

Ответить
Daniel Goldberg
Daniel Goldberg - 24.02.2023 22:29

great video! funny note, it looks like you edited out all of your blinks lmao

Ответить
Porcinetdu69
Porcinetdu69 - 29.12.2022 10:34

Why using « entre.Proprety.(e => e.dummyField).CurrentValue » ? I never really think about and always used « entry.Entity.dummyField ». Does it make any difference ?

Ответить
Emily Wagner
Emily Wagner - 17.11.2022 03:18

Milan, thanks for the awesome videos. What if you wanted to track the table columns affected, their previous values before CRUD and the new values after CRUD?

Ответить
William Liao
William Liao - 14.11.2022 21:53

a quick reminder from the case I encountered, there are two methods looks very similar in SaveChangesInterceptor, one is called SavingChangesAsync and one is call SavedChangesAsync, in thevideo we are implementing SavingChangesAsync. sometimes your IDE will aurocomplete to the other one. make sure you are overriding the correct method otherwise it won't work

Ответить
elpe21
elpe21 - 02.11.2022 02:01

There is 'Entity' property on EntityEntry through which you can access properties directly. Also the described method won't work if we want to keep track of IDs generated by the database on insert.

Ответить
Sergio M.
Sergio M. - 19.10.2022 01:02

Very useful video, thanks very much!

Ответить
John Cerpa
John Cerpa - 18.10.2022 18:43

Excellent, thank you

Ответить
Matthew Young
Matthew Young - 18.10.2022 00:26

Do you have a video on how you set up your visual studio? I love the way your Intellisense looks, and your color scheme. It looks like default with just a few nice modifications.

Ответить
TamerAli
TamerAli - 17.10.2022 18:37

Thanks Milan for your awesome video 👍
Is there a relation between Notification "e.g: like what SignalR do" and CQRS?
if yes, I hope you explain it in one of your upcoming videos
if no, I hope you also explain how to use it

Ответить
Bob Archer
Bob Archer - 16.10.2022 23:19

This is populating some audit fields but you still only have the latest state of the entity. There is no capture here of the values that were changed. Yes, I know when a change was made, and you can also include the user to know who changed it. But you don't know what was changed. This may be fine for some use cases.

One option to get a real audit log with changes is to use TemporalTables if you are in SQL server.

Or, if you really want a more robust method take a look at the EventSourcing pattern.

Ответить
Sunil Anthony
Sunil Anthony - 16.10.2022 22:01

Would this slow down your performance of the application?

Ответить
a85ihs
a85ihs - 16.10.2022 21:40

I thought you are tracking who made what changes with the dates.
Like when user add or delete anything entities get audited along with user info

Ответить
Fernando Calmet
Fernando Calmet - 16.10.2022 20:03

Milan, is it possible to capture here the ID of the person who made the modification or creation to save not only the date but also who made the transaction?

Ответить
Bảo Lee
Bảo Lee - 16.10.2022 07:57

I can do all this in the context file without register any services. Which one is better?

Ответить
Rajesh Kumar
Rajesh Kumar - 15.10.2022 05:19

Hi Milan,

Thanks for this.
is their any major performance impact if we follow this method for auditing or any other better way ?

Ответить
Shkelqim Haxha
Shkelqim Haxha - 14.10.2022 22:59

Hey Milan, great video. I have already implemented this kind of audit using EFCore, but I have found one setback in this. If you have related entities in your model, and for some reason it happens that the related entities are modified, then this way of audit will not work because EFCore change tracker doesn't track related entities (as per my experience). Have you found a workaround on this ?

Ответить
novaploča
novaploča - 14.10.2022 21:10

Using this implementation only last modified date will be written in db?

Ответить
unske
unske - 14.10.2022 20:46

I see .net video, I like

Ответить
Dmitry Stepanov
Dmitry Stepanov - 14.10.2022 17:56

What if you need to use the base SaveChanges method in certain cases? How do I disable the interceptor? In case with overriding SaveChanges it's easy.

Ответить
Biruk Ayalew
Biruk Ayalew - 14.10.2022 16:02

simple but useful 👍

Ответить
Bilal Mehrban
Bilal Mehrban - 14.10.2022 15:35

I see, seems interesting. Currently I am overriding the savechangesasync method but it has some issues in my use cases. This seems to resolve those definately will give it try :) Thanks :)

Ответить
Jakub Ormicki
Jakub Ormicki - 14.10.2022 15:09

Can you share a sample project with good DDD/CQRS pratices?

Ответить
Dave Arkley
Dave Arkley - 14.10.2022 14:37

How would one pass a username to this interceptor so that a name can be audited

Ответить
Mladen Stankovic
Mladen Stankovic - 14.10.2022 14:33

Opinions on using this approach vs having DB triggers for Insert/Update/Delete operations?

Ответить
Jo Lambrichts
Jo Lambrichts - 14.10.2022 14:21

Thanks, nice video. I think VS2022 has also the possibility to cleanup unused namespaces on file save

Ответить
KondzioSSJ4
KondzioSSJ4 - 14.10.2022 14:05

Is It possible to recaive link to github for that code?

Ответить