protected void RemoveCourseButton_Click(object sender, EventArgs e)
 {
     using (var context = new SchoolEntities())
     {
         var instructorID = Convert.ToInt32(InstructorsDropDownList.SelectedValue);
         var instructor = (from p in context.People
                           where p.PersonID == instructorID
                           select p).First();
         var courseID = Convert.ToInt32(AssignedCoursesDropDownList.SelectedValue);
         var courses = instructor.Courses;
         var courseToRemove = new Course();
         foreach (Course c in courses)
         {
             if (c.CourseID == courseID)
             {
                 courseToRemove = c;
                 break;
             }
         }
         try
         {
             courses.Remove(courseToRemove);
             context.SaveChanges();
             PopulateDropDownLists();
             CourseRemovedLabel.Text = "Removal successful.";
         }
         catch (Exception)
         {
             CourseRemovedLabel.Text = "Removal unsuccessful.";
             //Add code to log the error.
         }
         CourseRemovedLabel.Visible = true;
     }
 }
 /// <summary>
 /// Create a new Course object.
 /// </summary>
 /// <param name="courseID">Initial value of the CourseID property.</param>
 /// <param name="title">Initial value of the Title property.</param>
 /// <param name="credits">Initial value of the Credits property.</param>
 /// <param name="departmentID">Initial value of the DepartmentID property.</param>
 public static Course CreateCourse(global::System.Int32 courseID, global::System.String title, global::System.Int32 credits, global::System.Int32 departmentID)
 {
     Course course = new Course();
     course.CourseID = courseID;
     course.Title = title;
     course.Credits = credits;
     course.DepartmentID = departmentID;
     return course;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Courses EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCourses(Course course)
 {
     base.AddObject("Courses", course);
 }