Why does the ObjectStateManager property not exist in my db context?

I need to return a list of recently added objects from the context of my database.

I read that I need to use an ObjectStateManager for this purpose. The problem is that my database context does not have an ObjectStateManager property.

Context works great for retrieving, adding, and updating objects.

I am using EF 5.0

 <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 

What can I do?

+50
c # entity-framework
Nov 27
source share
2 answers

Try the following:

 var manager = ((IObjectContextAdapter)dbContext).ObjectContext.ObjectStateManager; 
+90
Nov 27
source share

Try the following:

 dbContext.Entry(entity).State = EntityState.Modified; 
+7
Mar 31 '16 at 12:35
source share



All Articles