From my research, I read that calling DbContext.Entry(someEntity) would automatically attached the entity to the context.
However, when I do this I find that the entity's state is detached.
Can anyone shed some light on this and how the DbContect.Entry works. I'm using EF 5.0
Thanks.
If you're wanting to attach an object, what you actually want is DbSet.Attach. DbContext.Entry is only giving you information about the entity, and allows you to change the state if it's already been attached.
Here's a good post about entity states from MSDN
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With