I have a piece of try catch code:
try
{
...
}
catch(Exception ex)
{
ModelState.AddModelError(
\"duplicateInvoiceNumberOrganisation\", \"The com
You can take a look at the SQLException class -- and check for the contents of the exception's message if it contains what you now see in your inner exception..Something like this:
try
{
//your code here
}
catch (SQLException ex)
{
if (ex.Message.Contains("Cannot insert duplicate key in obj...."))
{
//your code here
}
}