public PatientStore(ApplicationDbContext context, OwnerStore ownerStore) { Context = context; OwnerStore = ownerStore; OwnerPatient = Context.OwnersPatients .Include(x => x.Owner) .Include(x => x.Patient) .ToList(); }
internal void AddPatient(Patient patient) { Owner owner = OwnerStore.GetOwnerById(patient.OwnerId); OwnerPatient pp = new OwnerPatient { PatientId = patient.Id, OwnerId = owner.Id }; Context.Add(pp);//Esta línea es la que agrega la relación a la tabla intermedia. Context.Patients.Add(patient); Context.SaveChanges(); }