EF4 - ChangeObjectState is no longer available in RC

After porting EF4 CTP5 to RC1, I noticed that ObjectContext is no longer available through DbContext. This means that I cannot access the ChangeObjectState method.

class DataContext : DbContext { public DataContext() { } public DataContext(DbCompiledModel dbModel) : base(dbModel) { } public DbSet<MyClass> MyClasses { get; set; } public void ChangeObjectState<T>(T entity, EntityState entityState) { // this is no longer working.. where is ObjectContext? ObjectContext.ChangeObjectState(entity, entityState); } } 

Does anyone know how to access this method in RC1?

Thanks.

+4
source share
1 answer

You do not need to access the ObjectContext to change the state of the object. Use this:

 this.Entry<T>(entity).State = entityState; 
+7
source

Source: https://habr.com/ru/post/1345413/


All Articles