So here is a quick hack
try
{
context.SaveChanges();
}
catch (DbUpdateException e)
{
SqlException innerException = null;
Exception tmp = e;
while(innerException == null && tmp!=null)
{
if (tmp != null)
{
innerException = tmp.InnerException as SqlException;
tmp = tmp.InnerException;
}
}
if (innerException != null && innerException.Number == 2601)
{
// handle exception
}
else
{
throw;
}
}
I hope there is a better solution...