Saturday, February 12, 2011

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

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?

  • 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.

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

0 comments:

Post a Comment