1

I have a question that I've yet to find an answer to after some research. Is there a way in Code First for Entity to create an Insert/Update/Delete Trigger? Currently I cannot find anything and the only thing eluding to it was suggestions of using code to do whatever work (insert/update/delete) after a method fires.

1
  • You can probably do this in a customer database initializer. Commented Feb 27, 2013 at 18:00

1 Answer 1

2

Entity Framework currently does not support creating triggers on the database itself, nor does there appear to be any in the near future (see what's being implemented for EF 6 here).

The only solution that you have is to do whatever it is you wanted to do after the Insert/Update/Delete finishes, preferably in your business logic (or, even better, in your repositories if you want to set it up like in this blog post).

Sign up to request clarification or add additional context in comments.

2 Comments

That's what I feared. Seems like something they would want to invest in. I have a way around it though since I have a start up script when my project is first deployed. I could add the trigger then. Thanks.
+1 on the answer, "preferably in your business logic" is the right way of doing things.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.