public List <Car> GetCarsById(int id)
 {
     using (var context = new PeopleCarContext(_connection))
     {
         return(context.Cars.Where(c => c.PersonId == id).ToList());
     }
 }
 public Person GetPersonById(int id)
 {
     using (var context = new PeopleCarContext(_connection))
     {
         return(context.People.FirstOrDefault(p => p.Id == id));
     }
 }
 public List <Person> GetPeopleWithCars()
 {
     using (var context = new PeopleCarContext(_connection))
     {
         return(context.People.Include(p => p.Cars).ToList());
     }
 }
 public void DeleteCars(int id)
 {
     using (var context = new PeopleCarContext(_connection))
     {
         context.RemoveRange(context.Cars.Where(c => c.PersonId == id));
         context.SaveChanges();
     }
 }
 public void AddCar(Car c)
 {
     using (var context = new PeopleCarContext(_connection))
     {
         context.Cars.Add(c);
         context.SaveChanges();
     }
 }
 public void AddPerson(Person p)
 {
     using (var context = new PeopleCarContext(_connection))
     {
         context.People.Add(p);
         context.SaveChanges();
     }
 }