Entity Framework Code First DateTime field update on modification

前端 未结 3 2092
夕颜
夕颜 2020-12-30 14:00

I have the following entity:

public class User
{
    public int UserId { get; set; }
    public string UserName { get;         


        
3条回答
  •  执念已碎
    2020-12-30 14:34

    You can do this only with migrations. Set defaultSqlValue parameter for UpdateDate property to "GETDATE()" or "GETUTCDATE()" and when you modify or add new entity you would need to set its value to null.

提交回复
热议问题