0

我的代码是。为什么在实体框架5中成功修改了分离的实体?

class Program 
     { 

      static NorthwindEntities context = new NorthwindEntities(); 

      static void Main(string[] args) 
      { 
     Order updateorder = new Order() { OrderID = 10256, ShipCountry = "444", ShipCity = "tehran" };    
       update(updateorder); 
      } 


      static public void update(Order updateorder) 
      { 

       context.Entry<Order>(updateorder).State = EntityState.Modified; 

       context.SaveChanges(); 

      } 
     } 

请帮帮我,我感到困惑,为什么脱离实体在数据库

回答

1

调用context.Entry<Order>(updateorder)重视的对象EF修改。