Update a single property of a record in Entity Framework Code First
How can I update a single property of a record without retrieving it first? I'm asking in the context of EF Code First 4.1 Says I have a class User, mapping to table Users in Database: class User { public int Id {get;set;} [Required] public string Name {get;set;} public DateTime LastActivity {get;set;} ... } Now I want to update LastActivity of a user. I have user id. I can easily do so by querying the user record, set new value to LastActivity, then call SaveChanges(). But this would result in a redundant query. I work around by using Attach method. But because EF throws a validation