I use an EDMX schema as my context. On a previous project where I didn't use a schema, I could change the entity state like this:
public void SaveProduct(Product product)
{
if (product.ProductID == 0)
context.Products.Add(product);
else
context.Entry(product).State = EntityState.Modified;
context.SaveChanges();
}
But in this project, I don't see .Entry
in my intellisense (and it won't suggest a namespace reference if I just type it in).
I tried to modify an entity ans save it. It worked properly.
So my two questions are:
- Why is .Entry
not in my intellisense anymore?
- Do we really need to change the entity state with a persistent Context or can we rely on .Net to do that properly?