koenbeuk / EntityFrameworkCore.Triggered

Triggers for EFCore. Respond to changes in your DbContext before and after they are committed to the database.
MIT License
554 stars 29 forks source link

Trigger not firing when using ExecuteDeleteAsync in EF Core 7.0 #175

Closed MhammdAli closed 1 year ago

MhammdAli commented 1 year ago

Hi all,

I'm having an issue with the new feature in EF Core 7.0 when using ExecuteDeleteAsync and ExecuteUpdateAsync. Specifically, the trigger is not firing because the ExecuteDeleteAsync method works as one SQL command.

Has anyone else encountered this issue, and if so, how did you solve it? Any insights or suggestions would be greatly appreciated.

Thanks in advance.

koenbeuk commented 1 year ago

I have not had a chance to use the new EF bulk update and delete features but from my understanding, this is not affecting EF's ChangeTracker but rather it gets applied directly on the database.

This project relies on EF's ChangeTracker to work. Triggers should therefore not be compatible with EF Cores bulk update features.

MhammdAli commented 1 year ago

I'm considering using CreateTriggerSession() in dbContext extension method to raise additional events. Is it safe to use this method in terms of performance and reliability?

koenbeuk commented 1 year ago

Yes, that method is exposed in case you want to fire additional trigger types or take control in when triggers should be fired. Transaction Triggers are an example of this.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.