On Insert / Update logic in EF code first

前端 未结 2 524
时光说笑
时光说笑 2020-12-09 10:59

I would like to add some logic to the insert and update events of some EF objects. I have a MVC application with category object which has a property which is a slugified ve

2条回答
  •  天命终不由人
    2020-12-09 11:15

    No there is no such extension point because your entity is POCO - it is not aware of its persistence. Such logic must be triggered in data access layer which is aware of persistence. DbContext API offers only overriding of SaveChanges.

    You can expose custom events or methods on your entities and call them during processing in SaveChanges.

提交回复
热议问题