How do I automatically update a ModifiedAt field with ADO.NET Entity Framework?

StackOverflow https://stackoverflow.com/questions/118343

  •  02-07-2019
  •  | 
  •  

Question

Ruby on Rails has magic timestamping fields that are automatically updated when a record is created or updated. I'm trying to find similar functionality in Entity Framework. I've considered database triggers and a SavingChanges event handler. Is there a more obvious method I'm overlooking?

Was it helpful?

Solution 2

I resorted to a SavingChanges event handler. Details on my blog.

OTHER TIPS

If you're using MS SQL Server, use a timestamp field. The value itself is meaningless, other than to tell you whether the record has been touched since your last retrieve.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top