Entity Framework 4.2 : Getting proper database errors
In my ASP.NET MVC 3 application, I use EF 4.2. In my database, I have a unique constraint for a column. I try to insert same data in order to see what I get but I am getting the below error: An error occurred while updating the entries. See the inner exception for details. Inside the inner exception I can see the full error about unique constraint. But how can I uniquely catch this exception to tell the user this: You are entering the same value again. Here is what I do currently: try { UpdateModel<ConditionType>(conditionType, null, null, new string[] { "ConditionTypeId" });