Frage

my code is .

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();

            }
        }

please help me , i confused why the detached entity is modified in database

War es hilfreich?

Lösung

the call to context.Entry<Order>(updateorder) attaches the object to EF.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top