I have a WPF DataGrid bound to some entities (Entity Framework 4+).
User then edits the DataGrid and presses SAVE. Data is then saved back to MS SQL Server 2008 using SaveChanges(). Well… now, I would like to have AUTOMATIC timestamp which stores the time of the last change and updates itself automatically.
Guys, is it possible? How?
Thank you, James
The easiest solution to achieve this is on the database level:
DateTimevalue.StoreGeneratedPatternfor the new property toComputedso the value generated in the database is correctly updated to your attached entity after each insert or update.If you don’t like the trigger you must do it manually in overriden SaveChanges where you find all entities which will be inserted or updated and set the column: