I have a Entity Framework code first approach, i am using DefaultValue constraint using [DefaultValue("1"), DatabaseGenerated(DatabaseGeneratedOption.Computed)]
on a bool field, my problem is even if i set any value to it, it ignores it and sets the value from DefaultConstraint.
Here's my model:
[DefaultValue("1"), DatabaseGenerated(DatabaseGeneratedOption.Computed)]
public bool IsFirstLogin { get; set; }
Here's my update function:
public void Update(out bool isEmailUpdated, Guid? userID = null)
{
var user = db.Users.Find(userID);
user.IsFirstLogin = false;
isEmailUpdated = false;
db.SaveChanges();
}
UPDATES
My concern is not about setting DefaultValue, it's properly being created, my concern is now when i try to set any value to the field, it does not updates with that value, means it automatically sets the Default value to the field. So my problem is with the updates.