70-516 · Question #132
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. The application uses the ADO.NET Entity Framework to model entities. The application includes a…
The correct answer is A. Add a handler for the ObjectContext.SavingChanges event. SavingChanges() Event Occurs when changes are saved to the data source. ObjectMaterialized() Event Occurs when a new entity object is created from data in the data source as part of a query or load operation. Attach() Method Attaches an object or object graph to the object…
Question
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. The application uses the ADO.NET Entity Framework to model entities. The application includes a Customer entity along with a CustomerKey property of the Guid type as shown in the following exhibit:
You discover that when the application adds a new instance of a Customer, calling the SaveChanges method results in the following error message:
"Server generated keys are only supported for identity columns." You need to ensure that the application can add new Customer entities. What should you do?
Options
- AAdd a handler for the ObjectContext.SavingChanges event.
- BAdd a handler for the ObjectContext.ObjectMaterialized event.
- CCall the ObjectContext.Attach method before saving a Customer entity.
- DCall the ObjectContext.CreateEntityKey method before saving a Customer entity.
How the community answered
(41 responses)- A80% (33)
- B10% (4)
- C7% (3)
- D2% (1)
Explanation
SavingChanges() Event Occurs when changes are saved to the data source. ObjectMaterialized() Event Occurs when a new entity object is created from data in the data source as part of a query or load operation. Attach() Method Attaches an object or object graph to the object context when the object has an CreateEntityKey() Creates the entity key for a specific object, or returns the entity key if it already ObjectContext Class
Topics
Community Discussion
No community discussion yet for this question.