I have a poco class like this
public Profile
{
public virtual int ID
{
get;
set;
}
public virtual string Description
{
get;
set;
}
public virtual bool Enabled
{
get;
set;
}
}
When i try to update like this
var prof = new Profile(){ ID = 1, Enabled = false };
context.Profiles.Single (s => s.ID == 1);
context.Profiles.ApplyCurrentValues(prof);
context.SaveChanges();
Sql says to me that Description does not allow NULL, but i’m not updating the “Description” column, I want to update just the “Enabled” field.
What’s wrong?
Tks
Try this instead:
As you can see I didn’t need to load the entity first from database. I was able to set which property was modified on detached entity.