I have a question that I have not been able to resolve.
If I have for example a class person and this is related to an address, in a separate table, one by one, then I create a person object, I set its address object and when saving with savechanges it saves the user and the address " in cascade ".
That's fine and it should be, now, this person also has a profile, the person set a profile, but when saving I do not want to generate a record in the profiles table, but only save the idperfil
in the table people, bone that does not keep "in cascade".
Is there a way to set or configure the person class so that it does not cascade? Thank you very much
--- edition --- There is something I do not understand, here I pass the code and my insert
public Boolean insert()
{
try
{
using (ModelSistema contexto = new ModelSistema())
{
MotivoFallecimiento a = this.toEntity();
contexto.MotivosFallecimientos.Add(a);
contexto.SaveChanges();
return true;
}
}
catch (Exception e)
{
return false;
}
}
in the reason of death table I have the user ID of the person in charge of the motivation in the system. What happens is that when you save the motivofallecimiento saves a user tuple in the users table, but should not, you should only save the user id in the table groundsfallecimiento so that the relationship remains, I hope you understand a little more.