What is the equivalent of ObjectContext.ApplyCurrentValues for DbContext

There is no equivalent. You can either get the ObjectContext with…

((IObjectContextAdapter)myDbContext).ObjectContext.ApplyCurrentValues(...)

…or use a similar method of DbEntityEntry:

 myDbContext.Entry(originalEntity).CurrentValues.SetValues(changedEntity);

originalEntity represents the object before the change (usually fetched from database before you update). It must be attached to the context. changedEntity represents the entity with the same key which has been changed.

This second approach is probably closely related to the ObjectStateEntry.ApplyCurrentValues method of EF 4.0
.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)