views:

23

answers:

1

Hi All,

I have created a data model with in EF 4.0, however I am not sure how I can capture things like Triggers in this model so that if others were to deploy it the Tables, Views, Triggers, etc would go along with it. Is there a way to pull triggers into the model build?

Thanks!

--B

A: 

Putting event handlers on your entities is definitely not the same thing, but it might do the job depending on what you need. Some references I've used for this if you need them:

How to: Execute Business Logic During Scalar Property Changes

How to: Execute Business Logic When the Object State Changes

How to: Execute Business Logic When Saving Changes

Entity Framework (EF) – Events (this one's pretty good)

Not sure if you've already done what you wanted to do, but HTH.

Edit: One dumb mistake I made: Watch out for infinite loops if you use an OnPropertyChanged or OnPropertyChanging event to alter another property (in my case, it was MyEntity.DateModified).

Justin Morgan