1
I have in my Repospository, my method of deleting
public virtual void Deletar(int Id)
{
var entity = _dbSet.Find(Id);
_dbSet.Remove(entity);
}
The problem is that it is deleting even if it is with FK in another table, and I don’t want it to delete, which is wrong?
You have to create database contraints. There is no magic. Or else validate via application, which is also not simple.
– Fernando Leal
Fernando, when generating the bank (code first) is already generated with FK
– Rod
Which database you use?
– Fernando Leal
Sql Server 2012
– Rod
It was to generate an exception in the database if there is the correct Constraint.
– Fernando Leal
Fernando, I found the bug already, was in a configuration of the Entity Framework
– Rod