public static void AddTeachers(Teacher Teacher) { using (var Model = new SchoolVolunteerModel()) { Model.Teachers.Add(Teacher); Model.SaveChanges(); // database connection terminated } }
//public string Kids { get; set; } #endregion #region Methods /// <summary> /// adding each family to the family list with this method /// </summary> /// <param name="family"></param> /// #region methods for Family public static void AddFamily(Family family, Volunteer volunteer, ClassRoom classroom) { using (var Model = new SchoolVolunteerModel()) { //Model is the connection name and we are creating an instance of the database connection //"using " is used to end the scope of the Datebase (closing the db) Model.Families.Add(family); Model.Volunteers.Add(volunteer); // Model.Teachers.Add(Teacher); Model.ClassRoom.Add(classroom); Model.SaveChanges(); }//by this time the database connection is terminated }