Entity Framework serialization
I was confused with my problem. I'm using Entity Framework and want to save entities on hard disk and then to restore them. I have no problem with Serializing/Deserializing but I get an exception "The object cannot be added to the ObjectStateManager because it already has an EntityKey. Use ObjectContext.Attach to attach an object that has an existing key" when I try to add deserialized object to my datacontext. And nothing happens when I just Att开发者_JAVA百科ach my entity to datacontext
How to achieve my goal?
You need to attach then add.
精彩评论