1
By default EF6 is enabled to delete in Select models, until we use the following convention:
modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
According to my searches it does not allow to delete the.
I have a model:
public class Cliente {
public ICollection<Contato> Contatos {get;set;}
public ICollection<Contrato> Contratos {get;set;}
public ICollection<Funcionario> Funcionarios {get;set;}
public ICollection<Fornecedor> Fornecedores {get;set}
etc...
}
My Client Model, there are numerous lists, but I would like that if it has nothing, in any of the lists, but have only in the Contacts list, it can be deleted in Scade, avoiding errors... Then if case, it has data beyond the Contacts list, it will give error...
The idea is:
If the Customer has only the Contact List as a reference, then he can delete everything, Client and his Contacts
If he has other ties, then he cannot exclude.
Motive:
I think I would lose a lot in performance, if I went to consult all the lists before removing...and also, could be reversed and I will not have the list, but there will be reference...
There is a way to enable Cascade for only one property ?