How to tell the user that a record has not been deleted because it has other entities to which it inherits its primary key via try/catch?
try
{
db.usuarios.Remove(usuario);
}
catch(?????)
{
???????
}
How to tell the user that a record has not been deleted because it has other entities to which it inherits its primary key via try/catch?
try
{
db.usuarios.Remove(usuario);
}
catch(?????)
{
???????
}
If you don't have cascading delete enabled you should handle the exception using something like be
Cannot catch SqlException in Entity Framework
by getting the sql exception you could loop through the errors and validate the
Number
to determine if there are any related toForeign Key violation