TagEntity framework

CreatedAt property with Entity framework

C

You’re building a new application, and you’re using Entity Framework Code First. Probably all your entities need an Id and CreatedAt/UpdatedAt property.
The sample below shows you how to define these properties in a base class, and (more importantly) how to set them correctly on every save, without setting them manually on every place where you’re changing things.

Software architect | Full-stack developer
Trainer | Speaker | Blogger

Categories