Microsoft Exam Questions

Which ObjectContext method should you call after changes are made to the entities?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The
application connects to a Microsoft SQL Server 2008 database. You use the ADO.NET Entity
Framework to model your entities. You use ADO.NET selftracking entities. You need to ensure that
the change-tracking information for the selttracking entities can be used to update the database.
Which ObjectContext method should you call after changes are made to the entities?

A.
Attach

B.
Refresh

C.
SaveChanges

D.
ApplyChanges

Explanation:
ApplyChanges takes the changes in a connected set of entities and applies them to an
ObjectContext.
Starting with Microsoft Visual Studio 2010, the ADO.NET Self-Tracking Entity Generator template
generates self-tracking entities.
This template item generates two .tt (text template) files: <model name>.tt and <model
name>.Context.tt.
The <model name>.tt file generates the entity types and a helper class that contains the changetracking logic that is used by self-tracking entities and the extension methods that allow setting state
on self-tracking entities.
The <model name>.Context.tt file generates a typed ObjectContext and an extension class that
contains ApplyChanges methods for the ObjectContext and ObjectSet classes. These methods
examine the change-tracking information that is contained in the graph of self-tracking entities to
infer the set of operations that must be performed to save the changes in the database.
Working with Self-Tracking Entities
(http://msdn.microsoft.com/en-us/library/ff407090.aspx)