1

I have an object in my entity model ( it is a view in the db getting data over a linked server). Anyways, when I call contex.savechanges(), it updates everything that is changed in the object model. I don't want to update that certain object. Is there a way to exclude that object from updating? I haven't been able to find any properties or methods that would work.

Thanks for any suggestions. Brian

Loganj99
  • 449
  • 2
  • 9
  • 26

2 Answers2

1

Set the object's state to Unchanged:

_context.Entry(myObject).State = EntityState.Unchanged;

MSDN docs for:

DbContext.Entry method

EntityState property

D Stanley
  • 149,601
  • 11
  • 178
  • 240
0

I ended up creating a class to use. Instead of changing things in the entity object, I just populated the object to use in the method. Works like a champ.

Loganj99
  • 449
  • 2
  • 9
  • 26