I have couple of entity who inherits base class with common fields like below:
[DataType(DataType.Text)]
[StringLength(100)]
public string CreatedBy { get; set; }
[DataType(DataType.DateTime)]
public DateTime? CreatedDate { get; set; }
[DataType(DataType.Text)]
[StringLength(100)]
public string ModifiedBy { get; set; }
[DataType(DataType.DateTime)]
public DateTime? ModifiedDate { get; set; }
I would like to fill these fields right before it goes to contex. Is there some events/method/handler which I may reuse to do some actions with entity before it placed to context? I would like these fields are filled at the time its added to context, not put to the database.
Solution: Entity Framework/SQL2008 - How to Automatically Update LastModified fields for Entities?