views:

31

answers:

2

Hi

Sorry to ask such a general question: what can cause EF to insert records but not update ?

I face a strange situation where i change an entity and when i call SaveChanges(), the changes are not committed in the DB. thanks Jon

A: 

Do you have a primary key defined?

slamidtfyn
yes i do have PK
John
Are you using a generated objectcontext or are you using POCO's
slamidtfyn
i use a generated objectcontext
John
+2  A: 

Are you keeping the ObjectContext alive for the entire lifetime of your entities? If not, when you re-attach the entities to a new ObjectContext for saving, the changes made may not be reflected and the entities may not be considered dirty.

JeffN825
Indeed i did a change that led to this. Not clear why i affects the object context but i commented and it began to work.
John