nerdexam
Microsoft

70-516 · Question #215

You have an existing ContosoEntities context object named context. Calling the SaveChanges() method on the context object generates an exception that has the following inner exception…

The correct answer is A. Examine the code to see how Color objects are allocated. See the full explanation below for the reasoning.

Question

You have an existing ContosoEntities context object named context. Calling the SaveChanges() method on the context object generates an exception that has the following inner exception:

System.Data.SqlClient.SqlException: Cannot insert duplicate key row in object 'dbo.Colors' with unique index 'IX_Colors'. You need to ensure that a call to SaveChanges() on the context object does not generate this exception. What should you do?

Options

  • AExamine the code to see how Color objects are allocated.
  • BAdd a try/catch statement around every call to the SaveChanges() method.
  • CRemove the unique constraint on the Name column in the Colors table.
  • DOverride the SaveChanges() method on the ContosoEntities class,

How the community answered

(20 responses)
  • A
    75% (15)
  • B
    5% (1)
  • C
    15% (3)
  • D
    5% (1)

Community Discussion

No community discussion yet for this question.

Full 70-516 Practice