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

c# entity-framework

Question

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

I have read that i have to use ObjectStateManager for this purpos. The problem is, that my database context does not have the ObjectStateManager property.

The context works fine for retrivieing, adding and updating objects though.

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?

1
55
11/27/2012 10:52:16 AM

Accepted Answer

Try this:

var manager = ((IObjectContextAdapter)dbContext).ObjectContext.ObjectStateManager;
104
11/27/2012 10:14:23 AM

Popular Answer

Try this:

dbContext.Entry(entity).State = EntityState.Modified;


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow