In entity framework code migrations i realize that unique indexes can be added to columns.But when an attempt is made to insert a duplicate value you get back error message from the data based in an SQL Exception wrapped in UpdateException.
This is not very user friendly to display to a user.
Is it best to query the database for the existence of the value and display a user friend error message?
If not, Is there a more intuitive way of doing uniqueness checks and displaying a user friendly error message ?
There must be a System.Data.SqlClient.SqlException in InnerException(s) of UpdateException. SqlException has a Number Property which addresses the cause of exception. SqlException also provides more detail about the error with other properties.