What is the difference between these two statements (Entity Framework)

Does anyone know the difference, if any, of the following statements?

_context.AddObject(user);

_context.Users.AddObject(user);

and

_context.Attach(user);

_context.Users.Attach(user);

thank

EDIT

Sorry, some kind of confusion:

I know the difference between AddObject and Attach, I mean, is there any difference in the way you use AddObject ie

_context.AddObject(user);
_context.Users.AddObject(user);
+5
source share
3 answers

An ObjectContext can have multiple sets with the same schema, so it is usually best to use an explicit set. those._context.Users.AddObject(user);

From MSDN :

In the .NET Framework version 4, we recommend using methods on the ObjectSet to perform creation, reading, deleting, attaching, and updating operations. ObjectSet comes from ObjectQuery, so it also works as a query object.

, .NET Framework 4, , ObjectSet, ObjectContext:

 AddObject   
 Attach
 ApplyCurrentValues
 ApplyOriginalValues
 DeleteObject
 Detach
+1

MSDN

:

AddObject Added, Attach Unchanged. SaveChanges(), , AddObject , , Attach, .

0

, .

context.AddObject(user) 

context.AddObject("UserEntitySet", user)

AddObject Attach , , , ObjectSet, , .

IMHO EFv1 (.NET 3.5 SP1), ObjectSet .

0