I am using EntityFramework v6.1.2.
I read some articles and know about AsNoTracking
extension.
When AsNoTracking
is called, it means that if the entity is not attached, the context and the entity updated "should fail".
But I have tried and updated successfully, my code is in below:
private readonly DemoObjectContext _objectContext = new DemoObjectContext();
var order = _objectContext.Orders.AsNoTracking().FirstOrDefault(x => x.Id == 1);(1 is the primary key)
order.OrderStatus = OrderStatus.Processing; // change the orderstatus
//_objectContext.Set<Order>().Attach(order);
_objectContext.Entry(order).State = EntityState.Modified;
_objectContext.SaveChanges();
Is something wrong or did EntityFramework(6.1.2) changed something?
Please help me