Hi,
I've requirement to update entity without selecting it first to avoid 2 database hits. I've googled and read a lot on this topic, all say to use Attach method but that does not seem working if my table has non nullable columns and I try to update entity without passing values in them.
My [User] table in database has Id (primary key), Name (Not NULL), Image (NULL) columns. Now if I try to edit the row using below sample code then it gives entity framework validation error for Name field that"The field Name is required". I am using Entity Framework 6.1
using(DBEntities DB = new DBEntities())
{
User user = new User(){ Id = 1 };
DB.Users.Attach(user);
user.Image = "";
DB.SaveChanges();
}Thanks,
Vikas