Main Page | Report this Page
.NET DotNet Forum Index  »  ADO .NET Forum  »  EF - How do I attach a "EntityKey" object for...
Page 1 of 1    

EF - How do I attach a "EntityKey" object for...

Author Message
Colbert Zhou [MSFT]...
Posted: Wed Sep 30, 2009 4:08 am
Guest
Hello Richs,

Attach() method is used to attach an object to an ObjectContext. The object
attached is usually retrieve from another place, like remote method call or
WCF service, or deserialized from file and so on. These objects are
supposed to have entity keys. AddObject() is supposed to add a new created
object to the ObjectContext. So we will see that prompt error message.

Actually, to add related objects, we can call Attach on ObjectContext to
attach object to the object context. Do this when the object already exists
in the data source but is currently not attched to the context. For more
information, see,
http://msdn.microsoft.com/en-us/library/bb896271.aspx
http://msdn.microsoft.com/en-us/library/bb896245.aspx


Best regards,
Ji Zhou
Microsoft Managed Newsgroup Support Team
 
 
Page 1 of 1    
All times are GMT - 5 Hours
The time now is Mon Dec 14, 2009 2:27 pm