private void EnterCourse2() { string name = "thermo" + DateTime.Now.ToString(); using (var db = new CourseraContext()) { Course course = new Course(); course.Name = name; db.Courses.Add(course); db.SaveChanges(); } }
private static void EnterCourse() { string name = ""; while (name != "0") { Console.WriteLine("Enter name of course (0 to exit):"); name = Console.ReadLine().Trim(); if (name != "0") { using (var db = new CourseraContext()) { Course course = new Course(); course.Name = name; db.Courses.Add(course); db.SaveChanges(); } } } }