EF 4.1 code-first adding a trigger to a table

前端 未结 2 1897
离开以前
离开以前 2020-12-30 03:00

What is the best way to add a trigger to a table created by code-first approach with EF 4.1?

A way I\'m cosidering is to execute a custom SQL query either in OnModel

2条回答
  •  渐次进展
    2020-12-30 03:24

    I'm not entirely sure what you mean. If you want an actual SQL trigger on the table, then I'd create the trigger, as normal, in SQL. If you mean you want some kind of processing/updating to occur in your code whenever one of you entity sets is modified, then I think you'd want to do a custom method that would be called whenever that entity set is updated.

提交回复
热议问题