Entity Framework ignore objects Insert/Update on SaveChanges()

Assume you have an object:

var myItem = new MyItem()
  Name = "Alex"

If you want to ignore this object when calling SaveChanges() to do UPDATE or INSERT into database just use this command:

Db.Entry(myItem).State = EntityState.Detached;

You may also like

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.