开发者

Entity Framework Code First On Insert method hooks

开发者 https://www.devze.com 2023-04-10 11:18 出处:网络
I\'m trying to attach an audit log to an entity I\'ve written, I\'m wondering if there are hooks into a context that I can override to provide the desired functionality.

I'm trying to attach an audit log to an entity I've written, I'm wondering if there are hooks into a context that I can override to provide the desired functionality.

What I'm looking to do is:

I could manually add this in a controller but I'd rather a more concrete solution, the desired effect is that no method can insert into the table without also inserting into the audit log.


This project shows how you can add pre- and post-action hooks into an Entity Framework 4.1 DbContext. You can either extend its HooksDbContext class or see how it implements the hooks in the code and change it to suit your purposes.

0

精彩评论

暂无评论...
验证码 换一张
取 消