Why can't I update one field in EF?

There is such a model:
public class Phone
{
 public int Id { get; set; }
 public string Name { get; set; }
 public string Company { get; set; }
 public int Price { get; set; }
 }


Trying to update the field Price of the phone with Id = 2:
Phone Phone = new Phone { Id = 2};
this.Db.Entry(Phone).Property<int>("Price").To currentvalue = 666;
await this.Db.SaveChangesAsync();</int>


No error occurs but the value is not changing. What's the problem?
June 8th 19 at 16:48
1 answer
June 8th 19 at 16:50
Solution
You it was attached to the context, but updates are not happening. Try to explicitly specify that the model is modified
this.Db.Entry(Phone).State = EntityState.Modified;
this.Db.SaveChanges();

Find more questions by tags C#Entity Framework