I work on an Entity Framework 6.1.3, ASP.NET MVC 5, Code First with an existing databse project. My database (SQL Server 2016) includes a table with a “ModifiedDate” (datetime, DEFAULT (getdate)) column. When trying to create a new record in browser the server applies the value automatically as it should be done.
Unfortunately, when I update an existing record the old ModifiedDate value as it is shown in the textbox is applied (not the current date). Moreover, the ModifiedDate textbox should always be inactive to the user, both when creating or editing a record (i.e. the user shouldn’t be allowed to enter a value himself).
This is the model class for the “Title” table:
public partial class Title
{
public int TitleID { get; set; }
[Column("Title")]
[Required]
[StringLength(50)]
public string Title1 { get; set; }
[DatabaseGenerated(DatabaseGeneratedOption.Computed)]
public DateTime? ModifiedDate { get; set; }
}
Any suggestions would be appreciated.
Darfer