How to track Many-to-Many fields? (EFCore) #603
-
I'm trying to make auditing work for many-to-many relationship for my tables, however, it isn't working
They are connected via Fluent API:
Audit Class code:
In OnModelCreating I have this (take a note that IncludeAny(t => t.Name.StartsWith("Client")) includes fluent-api-coded "ClientChosenPortraitPhotos" table)
I use However, when i'm executing that code
My Output gives me only:
And so, no changes for ChosenPortraitPhotos goes into the audit table. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
@thepirat000, Thank you for the reply, I've tried it, but this code now just don't create any audit logs at all.
And this too
|
Beta Was this translation helpful? Give feedback.
-
@thepirat000 Thanks a lot! Now it all works as intended (but actually not as I initially imagined, I'm still acclimating to databases after OOP) I will drop my code here in case someone will need it later (look! it's MANY many-to-many relationships!):
|
Beta Was this translation helpful? Give feedback.
Note that the first parameter of the
.MapTable<AuditType>("AuditedTableName", ...)
call must be the table name of the relation table you want to audit, and NOT the audit table, so your code should look like this: