Following my other question about the taunts of DbContext.Set I have another question about the taunts of EF Code First.
Now I have a method for my update that looks like this:
if (entity == null) throw new ArgumentNullException("entity"); Context.GetIDbSet<T>().Attach(entity); Context.Entry(entity).State = EntityState.Modified; Context.CommitChanges(); return entity;
Context is the interface of my own DbContext.
The problem I'm working with is how I handle
Context.Entry(entity).State
.
I went through this code and it works when I have a real live DbContext as an implementation of my Context interface. But when I put my fake context, I donβt know how to deal with it.
There is no constructor for the DbEntityEntry class, so I cannot just create a new one in my fake context.
Has anyone had any success with bullying or faking DbEntityEntry in your CodeFirst solutions?
Or is there a better way to handle state changes?
entity-framework ef-code-first
taylonr Feb 17 '11 at 10:13 2011-02-17 22:13
source share