I have the following situation with a method of deleting directory:
internal void DeleteDiretorio(Model.Diretorio diretorio)
{
using (var ctx = new TESTEntities())
{
var dir = ctx.DIRETORIO.FirstOrDefault(a => a.DIRETORIO_GUID == diretorio.DIRETORIO_GUID);
if (dir == null)
throw new ArquivoException("Diretorio não encontrado");
ctx.Entry(dir).State = System.Data.EntityState.Deleted;
ctx.SaveChanges();
}
}
This method is to delete according to the id, but directory it has a list of files so it does not allow deletion, how would this method in EF to delete with all files linked to the directory?