By default EF6 is enabled to cascade models, until we use the following convention:
modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
According to my research it does not allow deleting the cascade.
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 Model Client, there are many lists, but I would like it if it has nothing in any of the lists, but only in the Contacts list, it can be deleted cascade, avoiding errors ... if it has data besides the Contacts list, it will give error ...
The idea is:
If Customer only has the Contacts list as a reference, then it can delete everything, Customer and its Contacts
If he has other links, then he can not delete them.
Reason:
I think I would lose a lot in performance if I were to check all the lists before removing them ... and also, it may be the reverse and I will not have the list, but it will reference ...
Is there a way to enable cascade for just one property?