Entity Framework removing entities that have fk [closed]

1

I have in my repository, 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 do not want it to delete, what is wrong?

    
asked by anonymous 17.09.2014 / 15:46

1 answer

1

By default, the entity framework comes with Cascade enabled, so I disabled it and it was in my exception

  modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
    
17.09.2014 / 16:32