locked
Trigger in Entity Framework RRS feed

  • Question

  • I have a project using Entity Framework 4

    I have a table of users that is mapped to an Entity Framework class. 

    When a new user is added or their details are updated, I'd like to be able to send them an email with the new details.   The application contains various places where a user can update the details, and it would be time consuming to update all of them.

    I'd like to do something similar to an after update database trigger but at the entity framework level to send the email. Are there any event handlers that are fired when a new user is added or their details updated that I can tap into to send the email?

    Friday, December 7, 2012 10:05 AM

Answers

  • The ObjectContext has a SavingChanges event. You could check for modified/added user entities and add your custom logic there.
    • Proposed as answer by Alexander Sun Monday, December 10, 2012 1:55 AM
    • Marked as answer by Alexander Sun Thursday, December 20, 2012 7:47 AM
    Friday, December 7, 2012 3:27 PM