public static void Initialize(SchoolContext context)
        {
            context.Database.EnsureCreated();

            // Look for any students.
            if (context.Students.Any())
            {
                return;   // DB has been seeded
            }

            var students = new Student[]
            {
                new Student {
                    FirstMidName = "Ivan", LastName = "Alexander", EnrollmentDate = DateTime.Parse("2005-09-01")
                },
                new Student {
                    FirstMidName = "Mirko", LastName = "Alonso", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Asen", LastName = "Anand", EnrollmentDate = DateTime.Parse("2003-09-01")
                },
                new Student {
                    FirstMidName = "Kalina", LastName = "Baronova", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Yana", LastName = "Lilova", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Pitra", LastName = "Mandjarova", EnrollmentDate = DateTime.Parse("2001-09-01")
                },
                new Student {
                    FirstMidName = "Lila", LastName = "Norbekova", EnrollmentDate = DateTime.Parse("2003-09-01")
                },
                new Student {
                    FirstMidName = "Nilana", LastName = "Oranjeva", EnrollmentDate = DateTime.Parse("2005-09-01")
                }
            };

            foreach (Student s in students)
            {
                context.Students.Add(s);
            }
            context.SaveChanges();

            var courses = new Course[]
            {
                new Course {
                    CourseID = 1050, Title = "Chemistry", Credits = 3
                },
                new Course {
                    CourseID = 4022, Title = "Microeconomics", Credits = 3
                },
                new Course {
                    CourseID = 4041, Title = "Macroeconomics", Credits = 3
                },
                new Course {
                    CourseID = 1045, Title = "Calculus", Credits = 4
                },
                new Course {
                    CourseID = 3141, Title = "Trigonometry", Credits = 4
                },
                new Course {
                    CourseID = 2021, Title = "Composition", Credits = 3
                },
                new Course {
                    CourseID = 2042, Title = "Literature", Credits = 4
                }
            };

            foreach (Course c in courses)
            {
                context.Courses.Add(c);
            }
            context.SaveChanges();

            var enrollments = new Enrollment[]
            {
                new Enrollment {
                    StudentID = 1, CourseID = 1050, Grade = Grade.A
                },
                new Enrollment {
                    StudentID = 1, CourseID = 4022, Grade = Grade.C
                },
                new Enrollment {
                    StudentID = 1, CourseID = 4041, Grade = Grade.B
                },
                new Enrollment {
                    StudentID = 2, CourseID = 1045, Grade = Grade.B
                },
                new Enrollment {
                    StudentID = 2, CourseID = 3141, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 2, CourseID = 2021, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 3, CourseID = 1050
                },
                new Enrollment {
                    StudentID = 4, CourseID = 1050
                },
                new Enrollment {
                    StudentID = 4, CourseID = 4022, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 5, CourseID = 4041, Grade = Grade.C
                },
                new Enrollment {
                    StudentID = 6, CourseID = 1045
                },
                new Enrollment {
                    StudentID = 7, CourseID = 3141, Grade = Grade.A
                },
            };

            foreach (Enrollment e in enrollments)
            {
                context.Enrollments.Add(e);
            }
            context.SaveChanges();
        }
Exemple #2
0
        public static void Initialize(SchoolContext context)
        {
            context.Database.EnsureCreated();

            // Look for any students.
            if (context.Students.Any())
            {
                return;   // DB has been seeded
            }

            var students = new Student[]
            {
                //tinfo200:[2021-03-11-logan23b-dykstra1] - student test data
                new Student {
                    FirstMidName = "Carson", LastName = "Alexander", EnrollmentDate = DateTime.Parse("2005-09-01")
                },
                new Student {
                    FirstMidName = "Meredith", LastName = "Alonso", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Arturo", LastName = "Anand", EnrollmentDate = DateTime.Parse("2003-09-01")
                },
                new Student {
                    FirstMidName = "Gytis", LastName = "Barzdukas", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Yan", LastName = "Li", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Peggy", LastName = "Justice", EnrollmentDate = DateTime.Parse("2001-09-01")
                },
                new Student {
                    FirstMidName = "Laura", LastName = "Norman", EnrollmentDate = DateTime.Parse("2003-09-01")
                },
                new Student {
                    FirstMidName = "Nino", LastName = "Olivetto", EnrollmentDate = DateTime.Parse("2005-09-01")
                }
            };

            foreach (Student s in students)
            {
                context.Students.Add(s);
            }
            context.SaveChanges();

            var courses = new Course[]
            {
                //tinfo200:[2021-03-11-logan23b-dykstra1] - courses test data
                new Course {
                    CourseID = 1050, Title = "Chemistry", Credits = 3
                },
                new Course {
                    CourseID = 4022, Title = "Microeconomics", Credits = 3
                },
                new Course {
                    CourseID = 4041, Title = "Macroeconomics", Credits = 3
                },
                new Course {
                    CourseID = 1045, Title = "Calculus", Credits = 4
                },
                new Course {
                    CourseID = 3141, Title = "Trigonometry", Credits = 4
                },
                new Course {
                    CourseID = 2021, Title = "Composition", Credits = 3
                },
                new Course {
                    CourseID = 2042, Title = "Literature", Credits = 4
                }
            };

            foreach (Course c in courses)
            {
                context.Courses.Add(c);
            }
            //tinfo200:[2021-03-11-logan23b-dykstra1] - database object saving these changes
            context.SaveChanges();

            var enrollments = new Enrollment[]
            {
                //tinfo200:[2021-03-11-logan23b-dykstra1] - enrollment test data
                //tinfo200:[2021-03-11-logan23b-dykstra1] - grade can be null (don't need one)
                new Enrollment {
                    StudentID = 1, CourseID = 1050, Grade = Grade.A
                },
                new Enrollment {
                    StudentID = 1, CourseID = 4022, Grade = Grade.C
                },
                new Enrollment {
                    StudentID = 1, CourseID = 4041, Grade = Grade.B
                },
                new Enrollment {
                    StudentID = 2, CourseID = 1045, Grade = Grade.B
                },
                new Enrollment {
                    StudentID = 2, CourseID = 3141, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 2, CourseID = 2021, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 3, CourseID = 1050
                },
                new Enrollment {
                    StudentID = 4, CourseID = 1050
                },
                new Enrollment {
                    StudentID = 4, CourseID = 4022, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 5, CourseID = 4041, Grade = Grade.C
                },
                new Enrollment {
                    StudentID = 6, CourseID = 1045
                },
                new Enrollment {
                    StudentID = 7, CourseID = 3141, Grade = Grade.A
                },
            };

            foreach (Enrollment e in enrollments)
            {
                context.Enrollments.Add(e);
            }
            context.SaveChanges();
        }
Exemple #3
0
        public static void Initialize(SchoolContext context)
        {
            context.Database.EnsureCreated();

            // Look for any students.
            if (context.Students.Any())
            {
                return;   // DB has been seeded
            }

            var students = new Student[]
            {
                new Student {
                    FirstName = "Carson", LastName = "Alexander", EmailAddress = "*****@*****.**", YearRank = "Junior", AverageGrade = 3.4f, EnrollmentDate = DateTime.Parse("2005-09-01")
                },
                new Student {
                    FirstName = "Meredith", LastName = "Alonso", EmailAddress = "*****@*****.**", YearRank = "Junior", AverageGrade = 2.9f, EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstName = "Arturo", LastName = "Anand", EmailAddress = "*****@*****.**", YearRank = "Sophomore", AverageGrade = 3.9f, EnrollmentDate = DateTime.Parse("2003-09-01")
                },
                new Student {
                    FirstName = "Gytis", LastName = "Barzdukas", EmailAddress = "*****@*****.**", YearRank = "Freshmen", AverageGrade = 3.5f, EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstName = "Yan", LastName = "Li", EmailAddress = "*****@*****.**", YearRank = "Senior", AverageGrade = 2.3f, EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstName = "Peggy", LastName = "Justice", EmailAddress = "*****@*****.**", YearRank = "Junior", AverageGrade = 3.2f, EnrollmentDate = DateTime.Parse("2001-09-01")
                },
                new Student {
                    FirstName = "Laura", LastName = "Norman", EmailAddress = "*****@*****.**", YearRank = "Freshmen", AverageGrade = 3.1f, EnrollmentDate = DateTime.Parse("2003-09-01")
                },
                new Student {
                    FirstName = "Nino", LastName = "Olivetto", EmailAddress = "*****@*****.**", YearRank = "Senior", AverageGrade = 4.0f, EnrollmentDate = DateTime.Parse("2005-09-01")
                }
            };

            foreach (Student s in students)
            {
                context.Students.Add(s);
            }
            context.SaveChanges();

            var courses = new Course[]
            {
                new Course {
                    CourseID = 1050, Title = "Chemistry", Credits = 3, RoomNum = "BHS 409"
                },
                new Course {
                    CourseID = 4022, Title = "Microeconomics", Credits = 3, RoomNum = "CP 503"
                },
                new Course {
                    CourseID = 4041, Title = "Macroeconomics", Credits = 3, RoomNum = "WG 689"
                },
                new Course {
                    CourseID = 1045, Title = "Calculus", Credits = 4, RoomNum = "GWP 110"
                },
                new Course {
                    CourseID = 3141, Title = "Trigonometry", Credits = 4, RoomNum = "MAT 941"
                },
                new Course {
                    CourseID = 2021, Title = "Composition", Credits = 3, RoomNum = "WCG 001"
                },
                new Course {
                    CourseID = 2042, Title = "Literature", Credits = 4, RoomNum = "BB 276"
                }
            };

            foreach (Course c in courses)
            {
                context.Courses.Add(c);
            }
            context.SaveChanges();

            var enrollments = new Enrollment[]
            {
                new Enrollment {
                    StudentID = 1, CourseID = 1050, Grade = Grade.A
                },
                new Enrollment {
                    StudentID = 1, CourseID = 4022, Grade = Grade.C
                },
                new Enrollment {
                    StudentID = 1, CourseID = 4041, Grade = Grade.B
                },
                new Enrollment {
                    StudentID = 2, CourseID = 1045, Grade = Grade.B
                },
                new Enrollment {
                    StudentID = 2, CourseID = 3141, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 2, CourseID = 2021, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 3, CourseID = 1050
                },
                new Enrollment {
                    StudentID = 4, CourseID = 1050
                },
                new Enrollment {
                    StudentID = 4, CourseID = 4022, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 5, CourseID = 4041, Grade = Grade.C
                },
                new Enrollment {
                    StudentID = 6, CourseID = 1045
                },
                new Enrollment {
                    StudentID = 7, CourseID = 3141, Grade = Grade.A
                },
            };

            foreach (Enrollment e in enrollments)
            {
                context.Enrollments.Add(e);
            }
            context.SaveChanges();
        }
Exemple #4
0
        public static void Initialize(SchoolContext context)
        {
            if (context.Students.Any())
            {
                return;   // DB has been seeded
            }

            var students = new Student[]
            {
                new Student {
                    FirstMidName = "Carson", LastName = "Alexander", EnrollmentDate = DateTime.Parse("2005-09-01")
                },
                new Student {
                    FirstMidName = "Meredith", LastName = "Alonso", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Arturo", LastName = "Anand", EnrollmentDate = DateTime.Parse("2003-09-01")
                },
                new Student {
                    FirstMidName = "Gytis", LastName = "Barzdukas", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Yan", LastName = "Li", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Peggy", LastName = "Justice", EnrollmentDate = DateTime.Parse("2001-09-01")
                },
                new Student {
                    FirstMidName = "Laura", LastName = "Norman", EnrollmentDate = DateTime.Parse("2003-09-01")
                },
                new Student {
                    FirstMidName = "Nino", LastName = "Olivetto", EnrollmentDate = DateTime.Parse("2005-09-01")
                }
            };

            foreach (Student s in students)
            {
                context.Students.Add(s);
            }
            context.SaveChanges();

            var courses = new Course[]
            {
                new Course {
                    CourseID = 1050, Title = "Chemistry", Credits = 3
                },
                new Course {
                    CourseID = 4022, Title = "Microeconomics", Credits = 3
                },
                new Course {
                    CourseID = 4041, Title = "Macroeconomics", Credits = 3
                },
                new Course {
                    CourseID = 1045, Title = "Calculus", Credits = 4
                },
                new Course {
                    CourseID = 3141, Title = "Trigonometry", Credits = 4
                },
                new Course {
                    CourseID = 2021, Title = "Composition", Credits = 3
                },
                new Course {
                    CourseID = 2042, Title = "Literature", Credits = 4
                }
            };

            foreach (Course c in courses)
            {
                context.Courses.Add(c);
            }
            context.SaveChanges();

            var enrollments = new Enrollment[]
            {
                new Enrollment {
                    StudentID = 1, CourseID = 1050, Grade = Grade.A
                },
                new Enrollment {
                    StudentID = 1, CourseID = 4022, Grade = Grade.C
                },
                new Enrollment {
                    StudentID = 1, CourseID = 4041, Grade = Grade.B
                },
                new Enrollment {
                    StudentID = 2, CourseID = 1045, Grade = Grade.B
                },
                new Enrollment {
                    StudentID = 2, CourseID = 3141, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 2, CourseID = 2021, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 3, CourseID = 1050
                },
                new Enrollment {
                    StudentID = 4, CourseID = 1050
                },
                new Enrollment {
                    StudentID = 4, CourseID = 4022, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 5, CourseID = 4041, Grade = Grade.C
                },
                new Enrollment {
                    StudentID = 6, CourseID = 1045
                },
                new Enrollment {
                    StudentID = 7, CourseID = 3141, Grade = Grade.A
                },
            };

            foreach (Enrollment e in enrollments)
            {
                context.Enrollments.Add(e);
            }
            context.SaveChanges();
        }
Exemple #5
0
        public static void Initialize(SchoolContext context)
        {
            bool isDatabaseAllreadySeeded = context.Students.Any() &&
                                            context.Courses.Any() &&
                                            context.Enrollments.Any();

            // Look for any students.
            if (isDatabaseAllreadySeeded)
            {
                return;   // DB has been seeded
            }

            var students = new Student[]
            {
                new Student {
                    FirstMidName = "Emma", LastName = "Anderson", EnrollmentDate = DateTime.Parse("2020-08-10")
                },
                new Student {
                    FirstMidName = "Martin", LastName = "Petrov", EnrollmentDate = DateTime.Parse("2019-08-10")
                },
                new Student {
                    FirstMidName = "Victoria", LastName = "Kancheva", EnrollmentDate = DateTime.Parse("2019-08-10")
                },
                new Student {
                    FirstMidName = "Kris", LastName = "Kanchev", EnrollmentDate = DateTime.Parse("2020-08-10")
                },
                new Student {
                    FirstMidName = "Todor", LastName = "Todorov", EnrollmentDate = DateTime.Parse("2019-08-10")
                },
                new Student {
                    FirstMidName = "Isabella", LastName = "Morison", EnrollmentDate = DateTime.Parse("2020-08-10")
                },
                new Student {
                    FirstMidName = "Alexander", LastName = "Konstantinov", EnrollmentDate = DateTime.Parse("2020-08-10")
                },
                new Student {
                    FirstMidName = "Cvetelina", LastName = "Aleksieva", EnrollmentDate = DateTime.Parse("2019-08-10")
                }
            };

            context.Students.AddRange(students);
            context.SaveChanges();

            var instructors = new Instructor[]
            {
                new Instructor {
                    FirstMidName = "Alexander", LastName = "Trifonov",
                    HireDate     = DateTime.Parse("1995-03-11")
                },
                new Instructor {
                    FirstMidName = "Radostin", LastName = "Raikov",
                    HireDate     = DateTime.Parse("1990-02-22")
                },
                new Instructor {
                    FirstMidName = "Kristiqn", LastName = "Vachkov",
                    HireDate     = DateTime.Parse("1998-07-01")
                },
                new Instructor {
                    FirstMidName = "Gabriel", LastName = "Atanasov",
                    HireDate     = DateTime.Parse("2001-11-15")
                },
                new Instructor {
                    FirstMidName = "Mariq", LastName = "Litova",
                    HireDate     = DateTime.Parse("2004-02-12")
                }
            };

            context.Instructors.AddRange(instructors);
            context.SaveChanges();

            var departments = new Department[]
            {
                new Department {
                    Name         = "English", Budget = 350000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Trifonov").ID
                },
                new Department {
                    Name         = "Mathematics", Budget = 100000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Raikov").ID
                },
                new Department {
                    Name         = "Engineering", Budget = 350000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Vachkov").ID
                },
                new Department {
                    Name         = "Economics", Budget = 100000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Atanasov").ID
                },
            };

            context.Departments.AddRange(departments);
            context.SaveChanges();

            var courses = new Course[]
            {
                new Course {
                    CourseID     = 1050, Title = "Chemistry", Credits = 3,
                    DepartmentID = departments.Single(s => s.Name == "Engineering").DepartmentID
                },
                new Course {
                    CourseID     = 4022, Title = "Microeconomics", Credits = 3,
                    DepartmentID = departments.Single(s => s.Name == "Economics").DepartmentID
                },
                new Course {
                    CourseID     = 4041, Title = "Macroeconomics", Credits = 3,
                    DepartmentID = departments.Single(s => s.Name == "Economics").DepartmentID
                },
                new Course {
                    CourseID     = 1045, Title = "Calculus", Credits = 4,
                    DepartmentID = departments.Single(s => s.Name == "Mathematics").DepartmentID
                },
                new Course {
                    CourseID     = 3141, Title = "Trigonometry", Credits = 4,
                    DepartmentID = departments.Single(s => s.Name == "Mathematics").DepartmentID
                },
                new Course {
                    CourseID     = 2021, Title = "Composition", Credits = 3,
                    DepartmentID = departments.Single(s => s.Name == "English").DepartmentID
                },
                new Course {
                    CourseID     = 2042, Title = "Literature", Credits = 4,
                    DepartmentID = departments.Single(s => s.Name == "English").DepartmentID
                },
            };

            context.Courses.AddRange(courses);
            context.SaveChanges();

            var officeAssignments = new OfficeAssignment[]
            {
                new OfficeAssignment {
                    InstructorID = instructors.Single(i => i.LastName == "Atanasov").ID,
                    Location     = "Smith 17"
                },
                new OfficeAssignment {
                    InstructorID = instructors.Single(i => i.LastName == "Litova").ID,
                    Location     = "Gowan 27"
                },
                new OfficeAssignment {
                    InstructorID = instructors.Single(i => i.LastName == "Raikov").ID,
                    Location     = "Thompson 304"
                },
            };

            context.OfficeAssignments.AddRange(officeAssignments);
            context.SaveChanges();

            var courseInstructors = new CourseAssignment[]
            {
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Chemistry").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Atanasov").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Chemistry").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Vachkov").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Microeconomics").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Litova").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Macroeconomics").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Litova").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Calculus").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Raikov").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Trigonometry").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Vachkov").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Composition").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Trifonov").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Literature").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Trifonov").ID
                },
            };

            context.CourseAssignments.AddRange(courseInstructors);
            context.SaveChanges();



            var enrollments = new Enrollment[]
            {
                //new Enrollment{StudentID=1,CourseID=1050,Grade=Grade.A},
                //new Enrollment{StudentID=1,CourseID=4022,Grade=Grade.C},
                //new Enrollment{StudentID=1,CourseID=4041,Grade=Grade.B},
                //new Enrollment{StudentID=2,CourseID=1045,Grade=Grade.B},
                //new Enrollment{StudentID=2,CourseID=3141,Grade=Grade.F},
                //new Enrollment{StudentID=2,CourseID=2021,Grade=Grade.F},
                //new Enrollment{StudentID=3,CourseID=1050},
                //new Enrollment{StudentID=4,CourseID=1050},
                //new Enrollment{StudentID=4,CourseID=4022,Grade=Grade.F},
                //new Enrollment{StudentID=5,CourseID=4041,Grade=Grade.C},
                //new Enrollment{StudentID=6,CourseID=1045},
                //new Enrollment{StudentID=7,CourseID=3141,Grade=Grade.A},
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Anderson").ID,
                    CourseID  = courses.Single(c => c.Title == "Chemistry").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Anderson").ID,
                    CourseID  = courses.Single(c => c.Title == "Microeconomics").CourseID,
                    Grade     = Grade.A
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Anderson").ID,
                    CourseID  = courses.Single(c => c.Title == "Macroeconomics").CourseID,
                    Grade     = Grade.A
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Petrov").ID,
                    CourseID  = courses.Single(c => c.Title == "Calculus").CourseID,
                    Grade     = Grade.C
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Petrov").ID,
                    CourseID  = courses.Single(c => c.Title == "Trigonometry").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Petrov").ID,
                    CourseID  = courses.Single(c => c.Title == "Composition").CourseID,
                    Grade     = Grade.D
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Kancheva").ID,
                    CourseID  = courses.Single(c => c.Title == "Chemistry").CourseID,
                    Grade     = Grade.A
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Kancheva").ID,
                    CourseID  = courses.Single(c => c.Title == "Microeconomics").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Kanchev").ID,
                    CourseID  = courses.Single(c => c.Title == "Chemistry").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Todorov").ID,
                    CourseID  = courses.Single(c => c.Title == "Composition").CourseID,
                    Grade     = Grade.C
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Morison").ID,
                    CourseID  = courses.Single(c => c.Title == "Literature").CourseID,
                    Grade     = Grade.A
                }
            };

            context.Enrollments.AddRange(enrollments);
            context.SaveChanges();

            foreach (Enrollment e in enrollments)
            {
                var enrollmentInDataBase = context.Enrollments.Where(
                    s =>
                    s.Student.ID == e.StudentID &&
                    s.Course.CourseID == e.CourseID).SingleOrDefault();
                if (enrollmentInDataBase == null)
                {
                    context.Enrollments.Add(e);
                }
            }
            context.SaveChanges();
        }
Exemple #6
0
        public static void Initialize(SchoolContext context)
        {
            // Look for any students.
            if (context.Students.Any())
            {
                return;   // DB has been seeded
            }

            var alexander = new Student
            {
                FirstMidName   = "Carson",
                LastName       = "Alexander",
                EnrollmentDate = DateTime.Parse("2016-09-01")
            };

            var alonso = new Student
            {
                FirstMidName   = "Meredith",
                LastName       = "Alonso",
                EnrollmentDate = DateTime.Parse("2018-09-01")
            };

            var anand = new Student
            {
                FirstMidName   = "Arturo",
                LastName       = "Anand",
                EnrollmentDate = DateTime.Parse("2019-09-01")
            };

            var barzdukas = new Student
            {
                FirstMidName   = "Gytis",
                LastName       = "Barzdukas",
                EnrollmentDate = DateTime.Parse("2018-09-01")
            };

            var li = new Student
            {
                FirstMidName   = "Yan",
                LastName       = "Li",
                EnrollmentDate = DateTime.Parse("2018-09-01")
            };

            var justice = new Student
            {
                FirstMidName   = "Peggy",
                LastName       = "Justice",
                EnrollmentDate = DateTime.Parse("2017-09-01")
            };

            var norman = new Student
            {
                FirstMidName   = "Laura",
                LastName       = "Norman",
                EnrollmentDate = DateTime.Parse("2019-09-01")
            };

            var olivetto = new Student
            {
                FirstMidName   = "Nino",
                LastName       = "Olivetto",
                EnrollmentDate = DateTime.Parse("2011-09-01")
            };

            var abercrombie = new Instructor
            {
                FirstMidName = "Kim",
                LastName     = "Abercrombie",
                HireDate     = DateTime.Parse("1995-03-11")
            };

            var fakhouri = new Instructor
            {
                FirstMidName = "Fadi",
                LastName     = "Fakhouri",
                HireDate     = DateTime.Parse("2002-07-06")
            };

            var harui = new Instructor
            {
                FirstMidName = "Roger",
                LastName     = "Harui",
                HireDate     = DateTime.Parse("1998-07-01")
            };

            var kapoor = new Instructor
            {
                FirstMidName = "Candace",
                LastName     = "Kapoor",
                HireDate     = DateTime.Parse("2001-01-15")
            };

            var zheng = new Instructor
            {
                FirstMidName = "Roger",
                LastName     = "Zheng",
                HireDate     = DateTime.Parse("2004-02-12")
            };

            var officeAssignments = new OfficeAssignment[]
            {
                new OfficeAssignment {
                    Instructor = fakhouri,
                    Location   = "Smith 17"
                },
                new OfficeAssignment {
                    Instructor = harui,
                    Location   = "Gowan 27"
                },
                new OfficeAssignment {
                    Instructor = kapoor,
                    Location   = "Thompson 304"
                },
            };

            context.AddRange(officeAssignments);

            var english = new Department
            {
                Name             = "English",
                Budget           = 350000,
                StartDate        = DateTime.Parse("2007-09-01"),
                Administrator    = abercrombie,
                ConcurrencyToken = Guid.NewGuid()
            };

            var mathematics = new Department
            {
                Name             = "Mathematics",
                Budget           = 100000,
                StartDate        = DateTime.Parse("2007-09-01"),
                Administrator    = fakhouri,
                ConcurrencyToken = Guid.NewGuid()
            };

            var engineering = new Department
            {
                Name             = "Engineering",
                Budget           = 350000,
                StartDate        = DateTime.Parse("2007-09-01"),
                Administrator    = harui,
                ConcurrencyToken = Guid.NewGuid()
            };

            var economics = new Department
            {
                Name             = "Economics",
                Budget           = 100000,
                StartDate        = DateTime.Parse("2007-09-01"),
                Administrator    = kapoor,
                ConcurrencyToken = Guid.NewGuid()
            };

            var chemistry = new Course
            {
                CourseID    = 1050,
                Title       = "Chemistry",
                Credits     = 3,
                Department  = engineering,
                Instructors = new List <Instructor> {
                    kapoor, harui
                }
            };

            var microeconomics = new Course
            {
                CourseID    = 4022,
                Title       = "Microeconomics",
                Credits     = 3,
                Department  = economics,
                Instructors = new List <Instructor> {
                    zheng
                }
            };

            var macroeconmics = new Course
            {
                CourseID    = 4041,
                Title       = "Macroeconomics",
                Credits     = 3,
                Department  = economics,
                Instructors = new List <Instructor> {
                    zheng
                }
            };

            var calculus = new Course
            {
                CourseID    = 1045,
                Title       = "Calculus",
                Credits     = 4,
                Department  = mathematics,
                Instructors = new List <Instructor> {
                    fakhouri
                }
            };

            var trigonometry = new Course
            {
                CourseID    = 3141,
                Title       = "Trigonometry",
                Credits     = 4,
                Department  = mathematics,
                Instructors = new List <Instructor> {
                    harui
                }
            };

            var composition = new Course
            {
                CourseID    = 2021,
                Title       = "Composition",
                Credits     = 3,
                Department  = english,
                Instructors = new List <Instructor> {
                    abercrombie
                }
            };

            var literature = new Course
            {
                CourseID    = 2042,
                Title       = "Literature",
                Credits     = 4,
                Department  = english,
                Instructors = new List <Instructor> {
                    abercrombie
                }
            };

            var enrollments = new Enrollment[]
            {
                new Enrollment {
                    Student = alexander,
                    Course  = chemistry,
                    Grade   = Grade.A
                },
                new Enrollment {
                    Student = alexander,
                    Course  = microeconomics,
                    Grade   = Grade.C
                },
                new Enrollment {
                    Student = alexander,
                    Course  = macroeconmics,
                    Grade   = Grade.B
                },
                new Enrollment {
                    Student = alonso,
                    Course  = calculus,
                    Grade   = Grade.B
                },
                new Enrollment {
                    Student = alonso,
                    Course  = trigonometry,
                    Grade   = Grade.B
                },
                new Enrollment {
                    Student = alonso,
                    Course  = composition,
                    Grade   = Grade.B
                },
                new Enrollment {
                    Student = anand,
                    Course  = chemistry,
                },
                new Enrollment {
                    Student = anand,
                    Course  = microeconomics,
                    Grade   = Grade.B
                },
                new Enrollment {
                    Student = barzdukas,
                    Course  = chemistry,
                    Grade   = Grade.B
                },
                new Enrollment {
                    Student = li,
                    Course  = composition,
                    Grade   = Grade.B
                },
                new Enrollment {
                    Student = justice,
                    Course  = literature,
                    Grade   = Grade.B
                }
            };

            context.AddRange(enrollments);
            context.SaveChanges();
        }
Exemple #7
0
        public static void Initialize(SchoolContext context)
        {
            context.Database.EnsureCreated();

            // Look for any courses.
            if (context.PCourses.Any())
            {
                return;   // DB has been seeded
            }



            //** ------------students------------ **//
            var students = new Student[]
            {
                new Student {
                    FirstMidName = "Carson", LastName = "Alexander", EnrollmentDate = DateTime.Parse("2005-09-01")
                },
                new Student {
                    FirstMidName = "Meredith", LastName = "Alonso", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Arturo", LastName = "Anand", EnrollmentDate = DateTime.Parse("2003-09-01")
                },
                new Student {
                    FirstMidName = "Gytis", LastName = "Barzdukas", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Yan", LastName = "Li", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Peggy", LastName = "Justice", EnrollmentDate = DateTime.Parse("2001-09-01")
                },
                new Student {
                    FirstMidName = "Laura", LastName = "Norman", EnrollmentDate = DateTime.Parse("2003-09-01")
                },
                new Student {
                    FirstMidName = "Nino", LastName = "Olivetto", EnrollmentDate = DateTime.Parse("2005-09-01")
                }
            };

            foreach (Student s in students)
            {
                context.Students.Add(s);
            }
            context.SaveChanges();



            //** ------------propedeuse------------ **//
            var pcourses = new PropedeuseCourse[]
            {
                new PropedeuseCourse {
                    ID      = 1,
                    code    = "IPMEDT1",
                    title   = "Project Mediatechnologie intro",
                    credits = 6
                },
                new PropedeuseCourse {
                    ID      = 2,
                    code    = "IMTHB",
                    title   = "Mediatechnologie HTML Basics",
                    credits = 3
                },
                new PropedeuseCourse {
                    ID      = 3,
                    code    = "IOPR1",
                    title   = "Objectgeoriënteerd programmeren 1",
                    credits = 4
                },
                new PropedeuseCourse {
                    ID      = 4,
                    code    = "IPBIT1",
                    title   = "Project Business IT intro",
                    credits = 5
                },
                new PropedeuseCourse {
                    ID      = 5,
                    code    = "ISMI",
                    title   = "Inleiding Business IT",
                    credits = 3
                },
                new PropedeuseCourse {
                    ID      = 6,
                    code    = "IBPM",
                    title   = "Inleiding informatiemanagement / BPM",
                    credits = 3
                },
                new PropedeuseCourse {
                    ID      = 7,
                    code    = "IOPR2",
                    title   = "Objectgeoriënteerd programmeren 2",
                    credits = 4
                },
                new PropedeuseCourse {
                    ID      = 8,
                    code    = "IPSEN",
                    title   = "MProject Software Engineering intro",
                    credits = 5
                },
                new PropedeuseCourse {
                    ID      = 9,
                    code    = "IMUML",
                    title   = "Modelleren in Unified Modelling Language",
                    credits = 3
                },
                new PropedeuseCourse {
                    ID      = 10,
                    code    = "IRDB",
                    title   = "Relationele Databases",
                    credits = 3
                },
                new PropedeuseCourse {
                    ID      = 11,
                    code    = "ITIM",
                    title   = "Toekomst, Innovatie & Media",
                    credits = 3
                },
                new PropedeuseCourse {
                    ID      = 12,
                    code    = "ICOMNL",
                    title   = "Inleiding communicatievaardigheden",
                    credits = 3
                },
                new PropedeuseCourse {
                    ID      = 13,
                    code    = "IPFIT1",
                    title   = "Project forensische ICT intro",
                    credits = 5
                },
                new PropedeuseCourse {
                    ID      = 14,
                    code    = "IFIT",
                    title   = "Inleiding Forensische ICT",
                    credits = 3
                },
                new PropedeuseCourse {
                    ID      = 15,
                    code    = "IWEB",
                    title   = "Webtechnologie",
                    credits = 3
                },
                new PropedeuseCourse {
                    ID      = 16,
                    code    = "INST",
                    title   = "IT netwerkstructuren",
                    credits = 3
                },
                new PropedeuseCourse {
                    ID      = 17,
                    code    = "ISL01",
                    title   = "Studieloopbaan begeleiding",
                    credits = 1
                }
            };

            foreach (PropedeuseCourse c in pcourses)
            {
                context.PCourses.Add(c);
            }
            context.SaveChanges();


            var keuzeVak = new KeuzevVak[]
            {
                new KeuzevVak {
                    ID      = 1,
                    code    = "IPMEDT1",
                    title   = "Project Mediatechnologie intro",
                    credits = 6
                },
                new KeuzevVak {
                    ID      = 2,
                    code    = "IMTHB",
                    title   = "Mediatechnologie HTML Basics",
                    credits = 3
                },
                new KeuzevVak {
                    ID      = 3,
                    code    = "IOPR1",
                    title   = "Objectgeoriënteerd programmeren 1",
                    credits = 4
                },
                new KeuzevVak {
                    ID      = 4,
                    code    = "IPBIT1",
                    title   = "Project Business IT intro",
                    credits = 5
                },
                new KeuzevVak {
                    ID      = 5,
                    code    = "ISMI",
                    title   = "Inleiding Business IT",
                    credits = 3
                },
                new KeuzevVak {
                    ID      = 6,
                    code    = "IBPM",
                    title   = "Inleiding informatiemanagement / BPM",
                    credits = 3
                },
                new KeuzevVak {
                    ID      = 7,
                    code    = "IOPR2",
                    title   = "Objectgeoriënteerd programmeren 2",
                    credits = 4
                },
                new KeuzevVak {
                    ID      = 8,
                    code    = "IPSEN",
                    title   = "MProject Software Engineering intro",
                    credits = 5
                },
                new KeuzevVak {
                    ID      = 9,
                    code    = "IMUML",
                    title   = "Modelleren in Unified Modelling Language",
                    credits = 3
                },
                new KeuzevVak {
                    ID      = 10,
                    code    = "IRDB",
                    title   = "Relationele Databases",
                    credits = 3
                },
                new KeuzevVak {
                    ID      = 11,
                    code    = "ITIM",
                    title   = "Toekomst, Innovatie & Media",
                    credits = 3
                },
                new KeuzevVak {
                    ID      = 12,
                    code    = "ICOMNL",
                    title   = "Inleiding communicatievaardigheden",
                    credits = 3
                },
                new KeuzevVak {
                    ID      = 13,
                    code    = "IPFIT1",
                    title   = "Project forensische ICT intro",
                    credits = 5
                },
                new KeuzevVak {
                    ID      = 14,
                    code    = "IFIT",
                    title   = "Inleiding Forensische ICT",
                    credits = 3
                },
                new KeuzevVak {
                    ID      = 15,
                    code    = "IWEB",
                    title   = "Webtechnologie",
                    credits = 3
                },
                new KeuzevVak {
                    ID      = 16,
                    code    = "INST",
                    title   = "IT netwerkstructuren",
                    credits = 3
                },
                new KeuzevVak {
                    ID      = 17,
                    code    = "ISL01",
                    title   = "Studieloopbaan begeleiding",
                    credits = 1
                }
            };

            foreach (PropedeuseCourse c in pcourses)
            {
                context.PCourses.Add(c);
            }
            context.SaveChanges();



            //** ------------mtCourses------------ **//
            var mtCourses = new MTCourse[]
            {
                new MTCourse {
                    ID      = 1,
                    code    = "IRDBMS",
                    title   = "Relationele Databasemanagementsystemen",
                    credits = 3
                },
                new MTCourse {
                    ID      = 2,
                    code    = "IPMEDT2",
                    title   = "Project Mediatechnologie 2",
                    credits = 6
                },
                new MTCourse {
                    ID      = 3,
                    code    = "IMTD1",
                    title   = "Mediatechnologie Design 1",
                    credits = 3
                },
                new MTCourse {
                    ID      = 4,
                    code    = "IQUA",
                    title   = "Kwaliteit in de IT",
                    credits = 3
                },
                new MTCourse {
                    ID      = 5,
                    code    = "IPMEDT3",
                    title   = "Project Mediatechnologie 3",
                    credits = 6
                },
                new MTCourse {
                    ID      = 6,
                    code    = "ITORG",
                    title   = "Inleiding Organisatiekunde",
                    credits = 3
                },
                new MTCourse {
                    ID      = 7,
                    code    = "IPMEDT4",
                    title   = "Project Mediatechnologie 4",
                    credits = 6
                },
                new MTCourse {
                    ID      = 8,
                    code    = "IMTPMD",
                    title   = "Programming for Mobile Devices",
                    credits = 3
                },
                new MTCourse {
                    ID      = 9,
                    code    = "ISEC",
                    title   = "IT Security",
                    credits = 3
                },
                new MTCourse {
                    ID      = 10,
                    code    = "IPMEDT5",
                    title   = "Project Mediatechnologie 5",
                    credits = 6
                },
                new MTCourse {
                    ID      = 11,
                    code    = "IMTHE1",
                    title   = "Mediatechnologie Hardware Engineering 1",
                    credits = 3
                },
                new MTCourse {
                    ID      = 12,
                    code    = "IFP2",
                    title   = "Projectmanagement volgens Prince 2",
                    credits = 3
                },
                new MTCourse {
                    ID      = 13,
                    code    = "IETH",
                    title   = "Ethiek",
                    credits = 3
                },
                new MTCourse {
                    ID      = 14,
                    code    = "IPMEDTH",
                    title   = "Project Mediatechnologie hoofdfase",
                    credits = 9
                },
                new MTCourse {
                    ID      = 15,
                    code    = "IMTCM",
                    title   = "Mediatechnologie Creative Marketing",
                    credits = 3
                },
                new MTCourse {
                    ID      = 16,
                    code    = "IMTMC",
                    title   = "Mediatechnologie Marketing en Communicatie",
                    credits = 3
                },
                new MTCourse {
                    ID      = 17,
                    code    = "ICOMH",
                    title   = "Communicatie hoofdfase",
                    credits = 3
                },
                new MTCourse {
                    ID      = 18,
                    code    = "ISLH1",
                    title   = "Studieloopbaanbegeleiding 2",
                    credits = 3
                },
                new MTCourse {
                    ID      = 19,
                    code    = "ISLH2",
                    title   = "Studieloopbaanbegeleiding 3",
                    credits = 1
                },
                new MTCourse {
                    ID      = 20,
                    code    = "ISLH3",
                    title   = "Studieloopbaanbegeleiding 4",
                    credits = 1
                },
                new MTCourse {
                    ID      = 21,
                    code    = "IMTHMI",
                    title   = "Human-Machine-interaction",
                    credits = 3
                },
                new MTCourse {
                    ID      = 22,
                    code    = "Minor",
                    title   = "Minor",
                    credits = 30
                },
                new MTCourse {
                    ID      = 23,
                    code    = "IWLS",
                    title   = "Stage",
                    credits = 30
                },
                new MTCourse {
                    ID      = 24,
                    code    = "IWLA",
                    title   = "Afstuderen",
                    credits = 30
                }
            };

            foreach (MTCourse c in mtCourses)
            {
                context.MtCourses.Add(c);
            }
            context.SaveChanges();



            //** ------------enrollment------------ **//
            var enrollments = new Enrollment[]
            {
                new Enrollment {
                    StudentID = 1, CourseID = 1050, Grade = Grade.A
                },
                new Enrollment {
                    StudentID = 1, CourseID = 4022, Grade = Grade.C
                },
                new Enrollment {
                    StudentID = 1, CourseID = 4041, Grade = Grade.B
                },
                new Enrollment {
                    StudentID = 2, CourseID = 1045, Grade = Grade.B
                },
                new Enrollment {
                    StudentID = 2, CourseID = 3141, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 2, CourseID = 2021, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 3, CourseID = 1050
                },
                new Enrollment {
                    StudentID = 4, CourseID = 1050
                },
                new Enrollment {
                    StudentID = 4, CourseID = 4022, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 5, CourseID = 4041, Grade = Grade.C
                },
                new Enrollment {
                    StudentID = 6, CourseID = 1045
                },
                new Enrollment {
                    StudentID = 7, CourseID = 3141, Grade = Grade.A
                },
            };

            foreach (Enrollment e in enrollments)
            {
                context.Enrollments.Add(e);
            }
            context.SaveChanges();
        }
Exemple #8
0
        public static void Initialize(SchoolContext context)
        {
            context.Database.EnsureCreated();

            // Look for any students.
            if (context.Students.Any())
            {
                return;   // DB has been seeded
            }

            //tinfo200:[2021-03-12-<meeras4>-dykstra2] - Purpose for test code is if there's no code found in database, the database will be created with loaded test data of arrays
            var students = new Student[]
            {
                //tinfo200:[2021-03-12-<meeras4>-dykstra2] - Assigning data for students
                new Student {
                    FirstMidName = "Carson", LastName = "Alexander", EnrollmentDate = DateTime.Parse("2005-09-01")
                },
                new Student {
                    FirstMidName = "Meredith", LastName = "Alonso", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Arturo", LastName = "Anand", EnrollmentDate = DateTime.Parse("2003-09-01")
                },
                new Student {
                    FirstMidName = "Gytis", LastName = "Barzdukas", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Yan", LastName = "Li", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Peggy", LastName = "Justice", EnrollmentDate = DateTime.Parse("2001-09-01")
                },
                new Student {
                    FirstMidName = "Laura", LastName = "Norman", EnrollmentDate = DateTime.Parse("2003-09-01")
                },
                new Student {
                    FirstMidName = "Nino", LastName = "Olivetto", EnrollmentDate = DateTime.Parse("2005-09-01")
                }
            };

            foreach (Student s in students)
            {
                context.Students.Add(s);
            }
            context.SaveChanges();

            var courses = new Course[]
            {
                //tinfo200:[2021-03-12-<meeras4>-dykstra2] - Assigning data for the courses
                new Course {
                    CourseID = 1050, Title = "Chemistry", Credits = 3
                },
                new Course {
                    CourseID = 4022, Title = "Microeconomics", Credits = 3
                },
                new Course {
                    CourseID = 4041, Title = "Macroeconomics", Credits = 3
                },
                new Course {
                    CourseID = 1045, Title = "Calculus", Credits = 4
                },
                new Course {
                    CourseID = 3141, Title = "Trigonometry", Credits = 4
                },
                new Course {
                    CourseID = 2021, Title = "Composition", Credits = 3
                },
                new Course {
                    CourseID = 2042, Title = "Literature", Credits = 4
                }
            };

            foreach (Course c in courses)
            {
                context.Courses.Add(c);
            }
            context.SaveChanges();

            var enrollments = new Enrollment[]
            {
                //tinfo200:[2021-03-12-<meeras4>-dykstra2] - Assigning grades for the enrollment classes
                new Enrollment {
                    StudentID = 1, CourseID = 1050, Grade = Grade.A
                },
                new Enrollment {
                    StudentID = 1, CourseID = 4022, Grade = Grade.C
                },
                new Enrollment {
                    StudentID = 1, CourseID = 4041, Grade = Grade.B
                },
                new Enrollment {
                    StudentID = 2, CourseID = 1045, Grade = Grade.B
                },
                new Enrollment {
                    StudentID = 2, CourseID = 3141, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 2, CourseID = 2021, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 3, CourseID = 1050
                },
                new Enrollment {
                    StudentID = 4, CourseID = 1050
                },
                new Enrollment {
                    StudentID = 4, CourseID = 4022, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 5, CourseID = 4041, Grade = Grade.C
                },
                new Enrollment {
                    StudentID = 6, CourseID = 1045
                },
                new Enrollment {
                    StudentID = 7, CourseID = 3141, Grade = Grade.A
                },
            };

            foreach (Enrollment e in enrollments)
            {
                context.Enrollments.Add(e);
            }
            context.SaveChanges();
        }
        public static void Initialize(SchoolContext context)
        {
            context.Database.EnsureCreated();

            // Look for any students.
            if (context.Students.Any())
            {
                return;   // DB has been seeded
            }

            // sample data for Student
            var students = new Student[]
            {
                new Student {
                    FirstName = "Carson", LastName = "Alexander", EmailAddress = "*****@*****.**", YearRank = "Junior", AverageGrade = 3.4f, EnrollmentDate = DateTime.Parse("2005-09-01")
                },
                new Student {
                    FirstName = "Meredith", LastName = "Alonso", EmailAddress = "*****@*****.**", YearRank = "Junior", AverageGrade = 2.9f, EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstName = "Arturo", LastName = "Anand", EmailAddress = "*****@*****.**", YearRank = "Sophomore", AverageGrade = 3.9f, EnrollmentDate = DateTime.Parse("2003-09-01")
                },
                new Student {
                    FirstName = "Gytis", LastName = "Barzdukas", EmailAddress = "*****@*****.**", YearRank = "Freshmen", AverageGrade = 3.5f, EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstName = "Yan", LastName = "Li", EmailAddress = "*****@*****.**", YearRank = "Senior", AverageGrade = 2.3f, EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstName = "Peggy", LastName = "Justice", EmailAddress = "*****@*****.**", YearRank = "Junior", AverageGrade = 3.2f, EnrollmentDate = DateTime.Parse("2001-09-01")
                },
                new Student {
                    FirstName = "Laura", LastName = "Norman", EmailAddress = "*****@*****.**", YearRank = "Freshmen", AverageGrade = 3.1f, EnrollmentDate = DateTime.Parse("2003-09-01")
                },
                new Student {
                    FirstName = "Nino", LastName = "Olivetto", EmailAddress = "*****@*****.**", YearRank = "Senior", AverageGrade = 4.0f, EnrollmentDate = DateTime.Parse("2005-09-01")
                }
            };

            foreach (Student s in students)
            {
                context.Students.Add(s);
            }
            context.SaveChanges();


            // sample data for Instructor
            var instructors = new Instructor[]
            {
                new Instructor {
                    FirstName = "Kim", LastName = "Abercrombie",
                    HireDate  = DateTime.Parse("1995-03-11")
                },
                new Instructor {
                    FirstName = "Fadi", LastName = "Fakhouri",
                    HireDate  = DateTime.Parse("2002-07-06")
                },
                new Instructor {
                    FirstName = "Roger", LastName = "Harui",
                    HireDate  = DateTime.Parse("1998-07-01")
                },
                new Instructor {
                    FirstName = "Candace", LastName = "Kapoor",
                    HireDate  = DateTime.Parse("2001-01-15")
                },
                new Instructor {
                    FirstName = "Roger", LastName = "Zheng",
                    HireDate  = DateTime.Parse("2004-02-12")
                },
                new Instructor {
                    FirstName = "John", LastName = "David",
                    HireDate  = DateTime.Parse("2004-03-10")
                }
            };

            foreach (Instructor i in instructors)
            {
                context.Instructors.Add(i);
            }
            context.SaveChanges();


            // sample data for Department
            var departments = new Department[]
            {
                new Department {
                    Name         = "English", Budget = 350000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Abercrombie").ID
                },
                new Department {
                    Name         = "Mathematics", Budget = 100000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Fakhouri").ID
                },
                new Department {
                    Name         = "Engineering", Budget = 350000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Harui").ID
                },
                new Department {
                    Name         = "Economics", Budget = 100000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Kapoor").ID
                },
                new Department {
                    Name         = "Information Technology", Budget = 200000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "David").ID
                }
            };

            foreach (Department d in departments)
            {
                context.Departments.Add(d);
            }
            context.SaveChanges();

            // sample data for Course
            var courses = new Course[]
            {
                new Course {
                    CourseID     = 1050, Title = "Chemistry", Credits = 3, RoomNum = "BHS 409",
                    DepartmentID = departments.Single(s => s.Name == "Engineering").DepartmentID
                },
                new Course {
                    CourseID     = 4022, Title = "Microeconomics", Credits = 3, RoomNum = "CP 503",
                    DepartmentID = departments.Single(s => s.Name == "Economics").DepartmentID
                },
                new Course {
                    CourseID     = 4041, Title = "Macroeconomics", Credits = 3, RoomNum = "WG 689",
                    DepartmentID = departments.Single(s => s.Name == "Economics").DepartmentID
                },
                new Course {
                    CourseID     = 1045, Title = "Calculus", Credits = 4, RoomNum = "GWP 110",
                    DepartmentID = departments.Single(s => s.Name == "Mathematics").DepartmentID
                },
                new Course {
                    CourseID     = 3141, Title = "Trigonometry", Credits = 4, RoomNum = "MAT 941",
                    DepartmentID = departments.Single(s => s.Name == "Mathematics").DepartmentID
                },
                new Course {
                    CourseID     = 2021, Title = "Composition", Credits = 3, RoomNum = "WCG 001",
                    DepartmentID = departments.Single(s => s.Name == "English").DepartmentID
                },
                new Course {
                    CourseID     = 2042, Title = "Literature", Credits = 4, RoomNum = "BB 276",
                    DepartmentID = departments.Single(s => s.Name == "English").DepartmentID
                },
                new Course {
                    CourseID     = 2078, Title = "ASP.NET MVC Web App", Credits = 4, RoomNum = "BB 276",
                    DepartmentID = departments.Single(s => s.Name == "English").DepartmentID
                }
            };

            foreach (Course c in courses)
            {
                context.Courses.Add(c);
            }
            context.SaveChanges();

            // sample data for Enrollment
            var enrollments = new Enrollment[]
            {
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Alexander").ID,
                    CourseID  = courses.Single(c => c.Title == "Chemistry").CourseID,
                    Grade     = Grade.A
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Alexander").ID,
                    CourseID  = courses.Single(c => c.Title == "Microeconomics").CourseID,
                    Grade     = Grade.C
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Alexander").ID,
                    CourseID  = courses.Single(c => c.Title == "Macroeconomics").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Alonso").ID,
                    CourseID  = courses.Single(c => c.Title == "Calculus").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Alonso").ID,
                    CourseID  = courses.Single(c => c.Title == "Trigonometry").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Alonso").ID,
                    CourseID  = courses.Single(c => c.Title == "Composition").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Anand").ID,
                    CourseID  = courses.Single(c => c.Title == "Chemistry").CourseID
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Anand").ID,
                    CourseID  = courses.Single(c => c.Title == "Microeconomics").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Barzdukas").ID,
                    CourseID  = courses.Single(c => c.Title == "Chemistry").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Li").ID,
                    CourseID  = courses.Single(c => c.Title == "Composition").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Justice").ID,
                    CourseID  = courses.Single(c => c.Title == "Literature").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Olivetto").ID,
                    CourseID  = courses.Single(c => c.Title == "Microeconomics").CourseID,
                    Grade     = Grade.A
                }
            };

            foreach (Enrollment e in enrollments)
            {
                var enrollmentInDataBase = context.Enrollments.Where(
                    s =>
                    s.Student.ID == e.StudentID &&
                    s.Course.CourseID == e.CourseID).SingleOrDefault();
                if (enrollmentInDataBase == null)
                {
                    context.Enrollments.Add(e);
                }
            }
            context.SaveChanges();


            // sample data for Office Assignment
            var officeAssignments = new OfficeAssignment[]
            {
                new OfficeAssignment {
                    InstructorID = instructors.Single(i => i.LastName == "Fakhouri").ID,
                    Location     = "Smith 17"
                },
                new OfficeAssignment {
                    InstructorID = instructors.Single(i => i.LastName == "Harui").ID,
                    Location     = "Gowan 27"
                },
                new OfficeAssignment {
                    InstructorID = instructors.Single(i => i.LastName == "Kapoor").ID,
                    Location     = "Thompson 304"
                },
                new OfficeAssignment {
                    InstructorID = instructors.Single(i => i.LastName == "David").ID,
                    Location     = "MAT 304"
                },
            };

            foreach (OfficeAssignment o in officeAssignments)
            {
                context.OfficeAssignments.Add(o);
            }
            context.SaveChanges();


            // sample data for Course Assignment
            var courseInstructors = new CourseAssignment[]
            {
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Chemistry").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Kapoor").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Chemistry").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Harui").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Microeconomics").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Zheng").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Macroeconomics").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Zheng").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Calculus").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Fakhouri").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Trigonometry").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Harui").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Composition").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Abercrombie").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Literature").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Abercrombie").ID
                },
            };

            foreach (CourseAssignment ci in courseInstructors)
            {
                context.CourseAssignments.Add(ci);
            }
            context.SaveChanges();
        }
Exemple #10
0
        public static void Initialize(SchoolContext context)
        {
            //tinfo200:[2021-03-13-hn98-dykstra1] -EF creates an empty database. In this section, a method is added that's called after the database is created in order to populate it with test data.
            context.Database.EnsureCreated();

            // Look for any students.
            if (context.Students.Any())
            {
                return;   // DB has been seeded
            }

            var students = new Student[]
            {
                new Student {
                    FirstMidName = "Carson", LastName = "Alexander", EnrollmentDate = DateTime.Parse("2005-09-01")
                },
                new Student {
                    FirstMidName = "Meredith", LastName = "Alonso", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Arturo", LastName = "Anand", EnrollmentDate = DateTime.Parse("2003-09-01")
                },
                new Student {
                    FirstMidName = "Gytis", LastName = "Barzdukas", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Yan", LastName = "Li", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Peggy", LastName = "Justice", EnrollmentDate = DateTime.Parse("2001-09-01")
                },
                new Student {
                    FirstMidName = "Laura", LastName = "Norman", EnrollmentDate = DateTime.Parse("2003-09-01")
                },
                new Student {
                    FirstMidName = "Nino", LastName = "Olivetto", EnrollmentDate = DateTime.Parse("2005-09-01")
                }
            };

            foreach (Student s in students)
            {
                context.Students.Add(s);
            }
            context.SaveChanges();

            var courses = new Course[]
            {
                new Course {
                    CourseID = 1050, Title = "Chemistry", Credits = 3
                },
                new Course {
                    CourseID = 4022, Title = "Microeconomics", Credits = 3
                },
                new Course {
                    CourseID = 4041, Title = "Macroeconomics", Credits = 3
                },
                new Course {
                    CourseID = 1045, Title = "Calculus", Credits = 4
                },
                new Course {
                    CourseID = 3141, Title = "Trigonometry", Credits = 4
                },
                new Course {
                    CourseID = 2021, Title = "Composition", Credits = 3
                },
                new Course {
                    CourseID = 2042, Title = "Literature", Credits = 4
                }
            };

            foreach (Course c in courses)
            {
                context.Courses.Add(c);
            }
            context.SaveChanges();

            var enrollments = new Enrollment[]
            {
                new Enrollment {
                    StudentID = 1, CourseID = 1050, Grade = Grade.A
                },
                new Enrollment {
                    StudentID = 1, CourseID = 4022, Grade = Grade.C
                },
                new Enrollment {
                    StudentID = 1, CourseID = 4041, Grade = Grade.B
                },
                new Enrollment {
                    StudentID = 2, CourseID = 1045, Grade = Grade.B
                },
                new Enrollment {
                    StudentID = 2, CourseID = 3141, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 2, CourseID = 2021, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 3, CourseID = 1050
                },
                new Enrollment {
                    StudentID = 4, CourseID = 1050
                },
                new Enrollment {
                    StudentID = 4, CourseID = 4022, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 5, CourseID = 4041, Grade = Grade.C
                },
                new Enrollment {
                    StudentID = 6, CourseID = 1045
                },
                new Enrollment {
                    StudentID = 7, CourseID = 3141, Grade = Grade.A
                },
            };

            foreach (Enrollment e in enrollments)
            {
                context.Enrollments.Add(e);
            }
            context.SaveChanges();
        }
Exemple #11
0
        public static void Initialize(SchoolContext context)
        {
            // context.Database.EnsureCreated();

            //this looks for any students
            if (context.Students.Any())
            {
                return;
            }
            var students = new Student[]
            {
                new Student {
                    FirstName = "Shuhratjan", LastName = "Nizamov", EnrollmentDate = DateTime.Parse("2005-09-01")
                },
                new Student {
                    FirstName = "Nurtileu", LastName = "Aliyas", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstName = "Moldir", LastName = "Kaliyas", EnrollmentDate = DateTime.Parse("2003-09-01")
                },
                new Student {
                    FirstName = "Nazym", LastName = "Soltumuratova", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstName = "Asanali", LastName = "Kereshov", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstName = "Muhamed", LastName = "Tolemis", EnrollmentDate = DateTime.Parse("2001-09-01")
                },
                new Student {
                    FirstName = "Saken", LastName = "Baymukhamed", EnrollmentDate = DateTime.Parse("2003-09-01")
                },
                new Student {
                    FirstName = "Asylzhan", LastName = "Erzhanov", EnrollmentDate = DateTime.Parse("2005-09-01")
                }
            };

            foreach (Student student in students)
            {
                context.Students.Add(student);
            }
            context.SaveChanges();

            var instructors = new Instructor[]
            {
                new Instructor {
                    FirstMidName = "Almas", LastName = "Byrleskenovich",
                    HireDate     = DateTime.Parse("2018-03-11")
                },
                new Instructor {
                    FirstMidName = "Gulbanu", LastName = "Khasenova",
                    HireDate     = DateTime.Parse("2002-07-06")
                },
                new Instructor {
                    FirstMidName = "Aizhan", LastName = "Doskozhanova",
                    HireDate     = DateTime.Parse("1998-07-01")
                },
                new Instructor {
                    FirstMidName = "Ilyas", LastName = "Zhuanishev",
                    HireDate     = DateTime.Parse("2001-01-15")
                },
                new Instructor {
                    FirstMidName = "Azamat", LastName = "Tolegenov",
                    HireDate     = DateTime.Parse("2004-02-12")
                }
            };

            foreach (Instructor i in instructors)
            {
                context.Instructors.Add(i);
            }
            context.SaveChanges();

            var departments = new Department[]
            {
                new Department {
                    Name         = "English", Budget = 350000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Doskozhanova").ID
                },
                new Department {
                    Name         = "Mathematics", Budget = 100000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Khasenova").ID
                },
                new Department {
                    Name         = "Engineering", Budget = 350000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Byrleskenovich").ID
                },
                new Department {
                    Name         = "Economics", Budget = 100000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Tolegenov").ID
                }
            };

            foreach (Department d in departments)
            {
                context.Departments.Add(d);
            }
            context.SaveChanges();

            var courses = new Course[]
            {
                new Course {
                    CourseID     = 1050, Title = "Chemistry", Credits = 3,
                    DepartmentID = departments.Single(s => s.Name == "Engineering").DepartmentID
                },
                new Course {
                    CourseID     = 4022, Title = "Microeconomics", Credits = 3,
                    DepartmentID = departments.Single(s => s.Name == "Economics").DepartmentID
                },
                new Course {
                    CourseID     = 4041, Title = "Macroeconomics", Credits = 3,
                    DepartmentID = departments.Single(s => s.Name == "Economics").DepartmentID
                },
                new Course {
                    CourseID     = 1045, Title = "Calculus", Credits = 4,
                    DepartmentID = departments.Single(s => s.Name == "Mathematics").DepartmentID
                },
                new Course {
                    CourseID     = 3141, Title = "Trigonometry", Credits = 4,
                    DepartmentID = departments.Single(s => s.Name == "Mathematics").DepartmentID
                },
                new Course {
                    CourseID     = 2021, Title = "Composition", Credits = 3,
                    DepartmentID = departments.Single(s => s.Name == "English").DepartmentID
                },
                new Course {
                    CourseID     = 2042, Title = "Literature", Credits = 4,
                    DepartmentID = departments.Single(s => s.Name == "English").DepartmentID
                },
            };

            foreach (Course c in courses)
            {
                context.Courses.Add(c);
            }
            context.SaveChanges();

            var officeAssignments = new OfficeAssignment[]
            {
                new OfficeAssignment {
                    InstructorID = instructors.Single(i => i.LastName == "Byrleskenovich").ID,
                    Location     = "Almaty 17"
                },
                new OfficeAssignment {
                    InstructorID = instructors.Single(i => i.LastName == "Khasenova").ID,
                    Location     = "Astana 27"
                },
                new OfficeAssignment {
                    InstructorID = instructors.Single(i => i.LastName == "Tolegenov").ID,
                    Location     = "Shymkent 304"
                },
            };

            foreach (OfficeAssignment o in officeAssignments)
            {
                context.OfficeAssignments.Add(o);
            }
            context.SaveChanges();

            var courseInstructors = new CourseAssignment[]
            {
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Chemistry").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Tolegenov").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Chemistry").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Khasenova").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Microeconomics").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Byrleskenovich").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Macroeconomics").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Byrleskenovich").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Calculus").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Zhuanishev").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Trigonometry").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Khasenova").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Composition").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Doskozhanova").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Literature").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Doskozhanova").ID
                },
            };

            foreach (CourseAssignment ci in courseInstructors)
            {
                context.CourseAssignments.Add(ci);
            }
            context.SaveChanges();

            var enrollments = new Enrollment[]
            {
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Nizamov").ID,
                    CourseID  = courses.Single(c => c.Title == "Chemistry").CourseID,
                    Grade     = Grade.A
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Aliyas").ID,
                    CourseID  = courses.Single(c => c.Title == "Microeconomics").CourseID,
                    Grade     = Grade.C
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Kaliyas").ID,
                    CourseID  = courses.Single(c => c.Title == "Macroeconomics").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Soltumuratova").ID,
                    CourseID  = courses.Single(c => c.Title == "Calculus").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Tolemis").ID,
                    CourseID  = courses.Single(c => c.Title == "Trigonometry").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Nizamov").ID,
                    CourseID  = courses.Single(c => c.Title == "Composition").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Aliyas").ID,
                    CourseID  = courses.Single(c => c.Title == "Chemistry").CourseID
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Kaliyas").ID,
                    CourseID  = courses.Single(c => c.Title == "Microeconomics").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Soltumuratova").ID,
                    CourseID  = courses.Single(c => c.Title == "Chemistry").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Erzhanov").ID,
                    CourseID  = courses.Single(c => c.Title == "Composition").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Baymukhamed").ID,
                    CourseID  = courses.Single(c => c.Title == "Literature").CourseID,
                    Grade     = Grade.B
                }
            };

            foreach (Enrollment e in enrollments)
            {
                var enrollmentInDataBase = context.Enrollments.Where(
                    s =>
                    s.Student.ID == e.StudentID &&
                    s.Course.CourseID == e.CourseID).SingleOrDefault();
                if (enrollmentInDataBase == null)
                {
                    context.Enrollments.Add(e);
                }
            }
            context.SaveChanges();
        }
Exemple #12
0
        public static void Initialize(SchoolContext context)
        { // tinfo200:[2021-03-12-kfrey02-dykstra2] added test database to the program so that the website has perceivable information inside the overarching database
            // tinfo200:[2021-03-12-kfrey02-dykstra2] the code will also add the information to the students context and save the changes that were made to the context
            context.Database.EnsureCreated();

            // Look for any students.
            if (context.Students.Any())
            {
                return;   // DB has been seeded
            }

            var students = new Student[]
            {
                new Student {
                    FirstMidName = "Carson", LastName = "Alexander", EnrollmentDate = DateTime.Parse("2005-09-01")
                },
                new Student {
                    FirstMidName = "Meredith", LastName = "Alonso", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Arturo", LastName = "Anand", EnrollmentDate = DateTime.Parse("2003-09-01")
                },
                new Student {
                    FirstMidName = "Gytis", LastName = "Barzdukas", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Yan", LastName = "Li", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Peggy", LastName = "Justice", EnrollmentDate = DateTime.Parse("2001-09-01")
                },
                new Student {
                    FirstMidName = "Laura", LastName = "Norman", EnrollmentDate = DateTime.Parse("2003-09-01")
                },
                new Student {
                    FirstMidName = "Nino", LastName = "Olivetto", EnrollmentDate = DateTime.Parse("2005-09-01")
                }
            };

            foreach (Student s in students)
            {
                context.Students.Add(s);
            }
            context.SaveChanges();

            var courses = new Course[]
            {
                new Course {
                    CourseID = 1050, Title = "Chemistry", Credits = 3
                },
                new Course {
                    CourseID = 4022, Title = "Microeconomics", Credits = 3
                },
                new Course {
                    CourseID = 4041, Title = "Macroeconomics", Credits = 3
                },
                new Course {
                    CourseID = 1045, Title = "Calculus", Credits = 4
                },
                new Course {
                    CourseID = 3141, Title = "Trigonometry", Credits = 4
                },
                new Course {
                    CourseID = 2021, Title = "Composition", Credits = 3
                },
                new Course {
                    CourseID = 2042, Title = "Literature", Credits = 4
                }
            };

            foreach (Course c in courses)
            {
                context.Courses.Add(c);
            }
            context.SaveChanges();

            var enrollments = new Enrollment[]
            {
                new Enrollment {
                    StudentID = 1, CourseID = 1050, Grade = Grade.A
                },
                new Enrollment {
                    StudentID = 1, CourseID = 4022, Grade = Grade.C
                },
                new Enrollment {
                    StudentID = 1, CourseID = 4041, Grade = Grade.B
                },
                new Enrollment {
                    StudentID = 2, CourseID = 1045, Grade = Grade.B
                },
                new Enrollment {
                    StudentID = 2, CourseID = 3141, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 2, CourseID = 2021, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 3, CourseID = 1050
                },
                new Enrollment {
                    StudentID = 4, CourseID = 1050
                },
                new Enrollment {
                    StudentID = 4, CourseID = 4022, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 5, CourseID = 4041, Grade = Grade.C
                },
                new Enrollment {
                    StudentID = 6, CourseID = 1045
                },
                new Enrollment {
                    StudentID = 7, CourseID = 3141, Grade = Grade.A
                },
            };

            foreach (Enrollment e in enrollments)
            {
                context.Enrollments.Add(e);
            }
            context.SaveChanges();
        }
Exemple #13
0
        public static void Initialize(SchoolContext context)
        {
            context.Database.EnsureCreated();

            // look for student
            if (context.Students.Any())
            {
                return; // DB has been seeded
            }
            // First time run
            var students = new Student[]
            {
                new Student {
                    FirstMidName   = "Sandeep Kumar",
                    LastName       = "Dewangan",
                    EnrollmentDate = DateTime.Parse("2021-09-01")
                },
                new Student {
                    FirstMidName   = "Khushbu",
                    LastName       = "Dewangan",
                    EnrollmentDate = DateTime.Parse("2021-09-01")
                },
                new Student {
                    FirstMidName   = "Tejaswini",
                    LastName       = "Dewangan",
                    EnrollmentDate = DateTime.Parse("2021-09-01")
                },
            };

            foreach (Student s in students)
            {
                context.Students.Add(s);
            }
            context.SaveChanges();

            var courses = new Course[]
            {
                new Course {
                    CourseID = 1050, Title = "Chemistry", Credits = 3
                },
                new Course {
                    CourseID = 4022, Title = "Microeconomics", Credits = 3
                },
                new Course {
                    CourseID = 4041, Title = "Macroeconomics", Credits = 3
                },
                new Course {
                    CourseID = 1045, Title = "Calculus", Credits = 4
                },
                new Course {
                    CourseID = 3141, Title = "Trigonometry", Credits = 4
                },
                new Course {
                    CourseID = 2021, Title = "Composition", Credits = 3
                },
                new Course {
                    CourseID = 2042, Title = "Literature", Credits = 4
                }
            };

            foreach (Course c in courses)
            {
                context.Courses.Add(c);
            }
            context.SaveChanges();
            var enrollments = new Enrollment[]
            {
                new Enrollment {
                    StudentID = 1, CourseID = 1050, Grade = Grade.A
                },
                new Enrollment {
                    StudentID = 1, CourseID = 4022, Grade = Grade.C
                },
                new Enrollment {
                    StudentID = 1, CourseID = 4041, Grade = Grade.B
                },
                new Enrollment {
                    StudentID = 2, CourseID = 1045, Grade = Grade.B
                },
                new Enrollment {
                    StudentID = 2, CourseID = 3141, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 2, CourseID = 2021, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 3, CourseID = 1050
                },
                new Enrollment {
                    StudentID = 4, CourseID = 1050
                },
                new Enrollment {
                    StudentID = 4, CourseID = 4022, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 5, CourseID = 4041, Grade = Grade.C
                },
                new Enrollment {
                    StudentID = 6, CourseID = 1045
                },
                new Enrollment {
                    StudentID = 7, CourseID = 3141, Grade = Grade.A
                },
            };

            foreach (Enrollment e in enrollments)
            {
                context.Enrollments.Add(e);
            }
            context.SaveChanges();
        }
        public static void Initialize(SchoolContext context)
        {
            context.Database.EnsureCreated();

            // Look for any students.
            if (context.Students.Any())
            {
                return;    // DB has been seeded
            }

            var students = new Student[]
            {
                new Student {
                    FirstName      = "Мила", LastName = "Милева",
                    EnrollmentDate = DateTime.Parse("2010-09-01")
                },
                new Student {
                    FirstName      = "Мария", LastName = "Петрова",
                    EnrollmentDate = DateTime.Parse("2012-09-01")
                },
                new Student {
                    FirstName      = "Пенка", LastName = "Димова",
                    EnrollmentDate = DateTime.Parse("2013-09-01")
                },
                new Student {
                    FirstName      = "Димитър", LastName = "Паскалев",
                    EnrollmentDate = DateTime.Parse("2012-09-01")
                },
                new Student {
                    FirstName      = "Жан", LastName = "Валжан",
                    EnrollmentDate = DateTime.Parse("2012-09-01")
                },
                new Student {
                    FirstName      = "Ния", LastName = "Желязкова",
                    EnrollmentDate = DateTime.Parse("2011-09-01")
                },
                new Student {
                    FirstName      = "Лаура", LastName = "Ботева",
                    EnrollmentDate = DateTime.Parse("2013-09-01")
                },
                new Student {
                    FirstName      = "Нино", LastName = "Пиронков",
                    EnrollmentDate = DateTime.Parse("2025-09-01")
                }
            };

            foreach (Student s in students)
            {
                context.Students.Add(s);
            }
            context.SaveChanges();

            var instructors = new Instructor[]
            {
                new Instructor {
                    FirstName = "Александър", LastName = "Добрев",
                    HireDate  = DateTime.Parse("1995-03-11")
                },
                new Instructor {
                    FirstName = "Симеон", LastName = "Иванов",
                    HireDate  = DateTime.Parse("2002-07-06")
                },
                new Instructor {
                    FirstName = "Крум", LastName = "Славов",
                    HireDate  = DateTime.Parse("1998-07-01")
                },
                new Instructor {
                    FirstName = "Ния", LastName = "Златанова",
                    HireDate  = DateTime.Parse("2001-01-15")
                },
                new Instructor {
                    FirstName = "Петя", LastName = "Вълканова",
                    HireDate  = DateTime.Parse("2004-02-12")
                }
            };

            foreach (Instructor i in instructors)
            {
                context.Instructors.Add(i);
            }
            context.SaveChanges();

            var departments = new Department[]
            {
                new Department {
                    Name         = "Макро икономика", Budget = 350000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Славов").ID
                },
                new Department {
                    Name         = "Микро икономика", Budget = 100000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Иванов").ID
                },
                new Department {
                    Name         = "Информатика", Budget = 350000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Добрев").ID
                },
                new Department {
                    Name         = "Екология", Budget = 100000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Златанова").ID
                }
            };

            foreach (Department d in departments)
            {
                context.Departments.Add(d);
            }
            context.SaveChanges();

            var courses = new Course[]
            {
                new Course {
                    CourseID     = 1050, Title = "Фондови пазари", Credits = 3,
                    DepartmentID = departments.Single(s => s.Name == "Макро икономика").DepartmentID
                },
                new Course {
                    CourseID     = 4022, Title = "Производителност на труда", Credits = 3,
                    DepartmentID = departments.Single(s => s.Name == "Микро икономика").DepartmentID
                },
                new Course {
                    CourseID     = 4041, Title = "Програмиране", Credits = 3,
                    DepartmentID = departments.Single(s => s.Name == "Информатика").DepartmentID
                },
                new Course {
                    CourseID     = 1045, Title = "Връзки с обществеността", Credits = 4,
                    DepartmentID = departments.Single(s => s.Name == "Микро икономика").DepartmentID
                },
                new Course {
                    CourseID     = 3141, Title = "Работа в екип", Credits = 4,
                    DepartmentID = departments.Single(s => s.Name == "Информатика").DepartmentID
                },
                new Course {
                    CourseID     = 2021, Title = "Опазване на околната среда", Credits = 3,
                    DepartmentID = departments.Single(s => s.Name == "Екология").DepartmentID
                },
                new Course {
                    CourseID     = 2042, Title = "Емоционална интелегентност", Credits = 4,
                    DepartmentID = departments.Single(s => s.Name == "Информатика").DepartmentID
                },
            };

            foreach (Course c in courses)
            {
                context.Courses.Add(c);
            }
            context.SaveChanges();

            var officeAssignments = new OfficeAssignment[]
            {
                new OfficeAssignment {
                    InstructorID = instructors.Single(i => i.LastName == "Златанова").ID,
                    Location     = "Стара Загора"
                },
                new OfficeAssignment {
                    InstructorID = instructors.Single(i => i.LastName == "Иванов").ID,
                    Location     = "Нова Згора"
                },
                new OfficeAssignment {
                    InstructorID = instructors.Single(i => i.LastName == "Добрев").ID,
                    Location     = "София"
                },
            };

            foreach (OfficeAssignment o in officeAssignments)
            {
                context.OfficeAssignments.Add(o);
            }

            context.SaveChanges();

            var courseInstructors = new CourseAssignment[]
            {
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Фондови пазари").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Златанова").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Производителност на труда").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Иванов").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Програмиране").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Добрев").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Опазване на околната среда").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Вълканова").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Връзки с обществеността").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Славов").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Работа в екип").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Вълканова").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Емоционална интелегентност").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Славов").ID
                }
            };

            foreach (CourseAssignment ci in courseInstructors)
            {
                context.CourseAssignments.Add(ci);
            }
            context.SaveChanges();

            var enrollments = new Enrollment[]
            {
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Димова").ID,
                    CourseID  = courses.Single(c => c.Title == "Фондови пазари").CourseID,
                    Grade     = Grade.A
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Милева").ID,
                    CourseID  = courses.Single(c => c.Title == "Производителност на труда").CourseID,
                    Grade     = Grade.C
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Валжан").ID,
                    CourseID  = courses.Single(c => c.Title == "Работа в екип").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Петрова").ID,
                    CourseID  = courses.Single(c => c.Title == "Програмиране").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Паскалев").ID,
                    CourseID  = courses.Single(c => c.Title == "Опазване на околната среда").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Пиронков").ID,
                    CourseID  = courses.Single(c => c.Title == "Връзки с обществеността").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Петрова").ID,
                    CourseID  = courses.Single(c => c.Title == "Фондови пазари").CourseID
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Ботева").ID,
                    CourseID  = courses.Single(c => c.Title == "Фондови пазари").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Димова").ID,
                    CourseID  = courses.Single(c => c.Title == "Програмиране").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Петрова").ID,
                    CourseID  = courses.Single(c => c.Title == "Връзки с обществеността").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Димова").ID,
                    CourseID  = courses.Single(c => c.Title == "Работа в екип").CourseID,
                    Grade     = Grade.B
                }
            };

            foreach (Enrollment e in enrollments)
            {
                var enrollmentInDataBase = context.Enrollments.Where(
                    s =>
                    s.Student.ID == e.StudentID &&
                    s.Course.CourseID == e.CourseID).SingleOrDefault();
                if (enrollmentInDataBase == null)
                {
                    context.Enrollments.Add(e);
                }
            }
            context.SaveChanges();
        }
Exemple #15
0
        public static void Initialize(SchoolContext context)
        {
            //context.Database.EnsureCreated();

            // Look for any students.
            if (context.Players.Any())
            {
                return;   // DB has been seeded
            }

            var players = new Player[]
            {
                new Player {
                    FirstMidName = "Carson", LastName = "Alexander",
                    ContractDate = DateTime.Parse("2016-09-01")
                },
                new Player {
                    FirstMidName = "Meredith", LastName = "Alonso",
                    ContractDate = DateTime.Parse("2018-09-01")
                },
                new Player {
                    FirstMidName = "Arturo", LastName = "Anand",
                    ContractDate = DateTime.Parse("2019-09-01")
                },
                new Player {
                    FirstMidName = "Gytis", LastName = "Barzdukas",
                    ContractDate = DateTime.Parse("2018-09-01")
                },
                new Player {
                    FirstMidName = "Yan", LastName = "Li",
                    ContractDate = DateTime.Parse("2018-09-01")
                },
                new Player {
                    FirstMidName = "Peggy", LastName = "Justice",
                    ContractDate = DateTime.Parse("2017-09-01")
                },
                new Player {
                    FirstMidName = "Laura", LastName = "Norman",
                    ContractDate = DateTime.Parse("2019-09-01")
                },
                new Player {
                    FirstMidName = "Nino", LastName = "Olivetto",
                    ContractDate = DateTime.Parse("2011-09-01")
                }
            };

            context.Players.AddRange(players);
            context.SaveChanges();

            var coaches = new Coach[]
            {
                new Coach {
                    FirstMidName = "Kim", LastName = "Abercrombie",
                    HireDate     = DateTime.Parse("1995-03-11")
                },
                new Coach {
                    FirstMidName = "Fadi", LastName = "Fakhouri",
                    HireDate     = DateTime.Parse("2002-07-06")
                },
                new Coach {
                    FirstMidName = "Roger", LastName = "Harui",
                    HireDate     = DateTime.Parse("1998-07-01")
                },
                new Coach {
                    FirstMidName = "Candace", LastName = "Kapoor",
                    HireDate     = DateTime.Parse("2001-01-15")
                },
                new Coach {
                    FirstMidName = "Roger", LastName = "Zheng",
                    HireDate     = DateTime.Parse("2004-02-12")
                }
            };

            context.Coaches.AddRange(coaches);
            context.SaveChanges();

            var departments = new Department[]
            {
                new Department {
                    Name      = "English", Budget = 350000,
                    StartDate = DateTime.Parse("2007-09-01"),
                    CoachID   = coaches.Single(i => i.LastName == "Abercrombie").ID
                },
                new Department {
                    Name      = "Mathematics", Budget = 100000,
                    StartDate = DateTime.Parse("2007-09-01"),
                    CoachID   = coaches.Single(i => i.LastName == "Fakhouri").ID
                },
                new Department {
                    Name      = "Engineering", Budget = 350000,
                    StartDate = DateTime.Parse("2007-09-01"),
                    CoachID   = coaches.Single(i => i.LastName == "Harui").ID
                },
                new Department {
                    Name      = "Economics", Budget = 100000,
                    StartDate = DateTime.Parse("2007-09-01"),
                    CoachID   = coaches.Single(i => i.LastName == "Kapoor").ID
                }
            };

            context.Departments.AddRange(departments);
            context.SaveChanges();

            var teams = new Team[]
            {
                new Team {
                    TeamID       = 1050, Title = "Chemistry", Credits = 3,
                    DepartmentID = departments.Single(s => s.Name == "Engineering").DepartmentID
                },
                new Team {
                    TeamID       = 4022, Title = "Microeconomics", Credits = 3,
                    DepartmentID = departments.Single(s => s.Name == "Economics").DepartmentID
                },
                new Team {
                    TeamID       = 4041, Title = "Macroeconomics", Credits = 3,
                    DepartmentID = departments.Single(s => s.Name == "Economics").DepartmentID
                },
                new Team {
                    TeamID       = 1045, Title = "Calculus", Credits = 4,
                    DepartmentID = departments.Single(s => s.Name == "Mathematics").DepartmentID
                },
                new Team {
                    TeamID       = 3141, Title = "Trigonometry", Credits = 4,
                    DepartmentID = departments.Single(s => s.Name == "Mathematics").DepartmentID
                },
                new Team {
                    TeamID       = 2021, Title = "Composition", Credits = 3,
                    DepartmentID = departments.Single(s => s.Name == "English").DepartmentID
                },
                new Team {
                    TeamID       = 2042, Title = "Literature", Credits = 4,
                    DepartmentID = departments.Single(s => s.Name == "English").DepartmentID
                },
            };

            context.Teams.AddRange(teams);
            context.SaveChanges();

            var officeAssignments = new OfficeAssignment[]
            {
                new OfficeAssignment {
                    CoachID  = coaches.Single(i => i.LastName == "Fakhouri").ID,
                    Location = "Smith 17"
                },
                new OfficeAssignment {
                    CoachID  = coaches.Single(i => i.LastName == "Harui").ID,
                    Location = "Gowan 27"
                },
                new OfficeAssignment {
                    CoachID  = coaches.Single(i => i.LastName == "Kapoor").ID,
                    Location = "Thompson 304"
                },
            };

            context.OfficeAssignments.AddRange(officeAssignments);
            context.SaveChanges();

            var teamCoaches = new TeamAssignment[]
            {
                new TeamAssignment {
                    TeamID  = teams.Single(c => c.Title == "Chemistry").TeamID,
                    CoachID = coaches.Single(i => i.LastName == "Kapoor").ID
                },
                new TeamAssignment {
                    TeamID  = teams.Single(c => c.Title == "Chemistry").TeamID,
                    CoachID = coaches.Single(i => i.LastName == "Harui").ID
                },
                new TeamAssignment {
                    TeamID  = teams.Single(c => c.Title == "Microeconomics").TeamID,
                    CoachID = coaches.Single(i => i.LastName == "Zheng").ID
                },
                new TeamAssignment {
                    TeamID  = teams.Single(c => c.Title == "Macroeconomics").TeamID,
                    CoachID = coaches.Single(i => i.LastName == "Zheng").ID
                },
                new TeamAssignment {
                    TeamID  = teams.Single(c => c.Title == "Calculus").TeamID,
                    CoachID = coaches.Single(i => i.LastName == "Fakhouri").ID
                },
                new TeamAssignment {
                    TeamID  = teams.Single(c => c.Title == "Trigonometry").TeamID,
                    CoachID = coaches.Single(i => i.LastName == "Harui").ID
                },
                new TeamAssignment {
                    TeamID  = teams.Single(c => c.Title == "Composition").TeamID,
                    CoachID = coaches.Single(i => i.LastName == "Abercrombie").ID
                },
                new TeamAssignment {
                    TeamID  = teams.Single(c => c.Title == "Literature").TeamID,
                    CoachID = coaches.Single(i => i.LastName == "Abercrombie").ID
                },
            };

            context.TeamAssignments.AddRange(teamCoaches);
            context.SaveChanges();

            var contracts = new Contract[]
            {
                new Contract {
                    PlayerID = players.Single(s => s.LastName == "Alexander").ID,
                    TeamID   = teams.Single(c => c.Title == "Chemistry").TeamID,
                    Grade    = Grade.A
                },
                new Contract {
                    PlayerID = players.Single(s => s.LastName == "Alexander").ID,
                    TeamID   = teams.Single(c => c.Title == "Microeconomics").TeamID,
                    Grade    = Grade.C
                },
                new Contract {
                    PlayerID = players.Single(s => s.LastName == "Alexander").ID,
                    TeamID   = teams.Single(c => c.Title == "Macroeconomics").TeamID,
                    Grade    = Grade.B
                },
                new Contract {
                    PlayerID = players.Single(s => s.LastName == "Alonso").ID,
                    TeamID   = teams.Single(c => c.Title == "Calculus").TeamID,
                    Grade    = Grade.B
                },
                new Contract {
                    PlayerID = players.Single(s => s.LastName == "Alonso").ID,
                    TeamID   = teams.Single(c => c.Title == "Trigonometry").TeamID,
                    Grade    = Grade.B
                },
                new Contract {
                    PlayerID = players.Single(s => s.LastName == "Alonso").ID,
                    TeamID   = teams.Single(c => c.Title == "Composition").TeamID,
                    Grade    = Grade.B
                },
                new Contract {
                    PlayerID = players.Single(s => s.LastName == "Anand").ID,
                    TeamID   = teams.Single(c => c.Title == "Chemistry").TeamID
                },
                new Contract {
                    PlayerID = players.Single(s => s.LastName == "Anand").ID,
                    TeamID   = teams.Single(c => c.Title == "Microeconomics").TeamID,
                    Grade    = Grade.B
                },
                new Contract {
                    PlayerID = players.Single(s => s.LastName == "Barzdukas").ID,
                    TeamID   = teams.Single(c => c.Title == "Chemistry").TeamID,
                    Grade    = Grade.B
                },
                new Contract {
                    PlayerID = players.Single(s => s.LastName == "Li").ID,
                    TeamID   = teams.Single(c => c.Title == "Composition").TeamID,
                    Grade    = Grade.B
                },
                new Contract {
                    PlayerID = players.Single(s => s.LastName == "Justice").ID,
                    TeamID   = teams.Single(c => c.Title == "Literature").TeamID,
                    Grade    = Grade.B
                }
            };

            foreach (Contract e in contracts)
            {
                var contractInDataBase = context.Contracts.Where(
                    s =>
                    s.Player.ID == e.PlayerID &&
                    s.Team.TeamID == e.TeamID).SingleOrDefault();
                if (contractInDataBase == null)
                {
                    context.Contracts.Add(e);
                }
            }
            context.SaveChanges();
        }
Exemple #16
0
        public static void Initialize(SchoolContext context)
        {
            // Look for any students
            if (context.Students.Any())
            {
                Console.WriteLine("Found one");
                // DB has data or has been seeded
                return;
            }
            Console.WriteLine("None found");

            // students
            var studentPM = new Student {
                FirstMidName = "Peter", LastName = "Mayaga", EnrollmentDate = DateTime.Parse("2015-05-03")
            };
            var studentJK = new Student {
                FirstMidName = "John", LastName = "Kampulunguse", EnrollmentDate = DateTime.Parse("2018-12-30")
            };
            var studentWS = new Student {
                FirstMidName = "Were", LastName = "Simon", EnrollmentDate = DateTime.Parse("2020-10-21")
            };
            var studentCJ = new Student {
                FirstMidName = "Collins", LastName = "Jackson", EnrollmentDate = DateTime.Parse("2009-01-02")
            };
            var studentMS = new Student {
                FirstMidName = "Matthew", LastName = "Sekitoleko", EnrollmentDate = DateTime.Parse("2021-3-23")
            };

            // instructors
            var instructor1 = new Instructor {
                FirstMidName = "John", LastName = "Ung", HireDate = DateTime.Parse("2001-04-14")
            };
            var instructor2 = new Instructor {
                FirstMidName = "Kabenge", LastName = "Moses", HireDate = DateTime.Parse("2005-01-29")
            };
            var instructor3 = new Instructor {
                FirstMidName = "Ssenoga", LastName = "Abram", HireDate = DateTime.Parse("2001-11-02")
            };
            var instructor4 = new Instructor {
                FirstMidName = "Wandegeya", LastName = "Kulekana", HireDate = DateTime.Parse("2015-10-30")
            };

            // OfficeAssignments
            var officeAssignments = new OfficeAssignment[]
            {
                new OfficeAssignment {
                    Instructor = instructor1, Location = "LLT-1A"
                },
                new OfficeAssignment {
                    Instructor = instructor3, Location = "LLT-2B"
                },
                new OfficeAssignment {
                    Instructor = instructor4, Location = "Big lab A"
                }
            };

            context.AddRange(officeAssignments);

            // departments
            var english = new Department
            {
                Name          = "English",
                Budget        = 300000,
                StartDate     = DateTime.Parse("1990-02-15"),
                Administrator = instructor1
            };
            var mathematics = new Department
            {
                Name          = "Mathematics",
                Budget        = 250000,
                StartDate     = DateTime.Parse("1960-10-25"),
                Administrator = instructor2
            };
            var cs = new Department
            {
                Name          = "Computer Science",
                Budget        = 500000,
                StartDate     = DateTime.Parse("1990-09-22"),
                Administrator = instructor3
            };

            // courses
            var chemistry = new Course
            {
                CourseID    = 1050,
                Title       = "Chemistry",
                Credits     = 3,
                Department  = mathematics,
                Instructors = new List <Instructor> {
                    instructor1, instructor2
                }
            };
            var SE = new Course
            {
                CourseID    = 5060,
                Title       = "Software Engineering",
                Credits     = 4,
                Department  = cs,
                Instructors = new List <Instructor> {
                    instructor2, instructor3
                }
            };
            var discreteMaths = new Course
            {
                CourseID    = 5090,
                Title       = "Discrete Mathematics",
                Credits     = 5,
                Department  = cs,
                Instructors = new List <Instructor> {
                    instructor2, instructor3, instructor4
                }
            };

            // Enrollments
            var enrollments = new Enrollment[]
            {
                new Enrollment
                {
                    Student = studentCJ,
                    Course  = chemistry,
                    Grade   = Grade.D
                },
                new Enrollment
                {
                    Student = studentJK,
                    Course  = discreteMaths
                },
                new Enrollment
                {
                    Student = studentPM,
                    Course  = SE,
                    Grade   = Grade.A
                },
                new Enrollment
                {
                    Student = studentJK,
                    Course  = SE,
                    Grade   = Grade.B
                },
                new Enrollment
                {
                    Student = studentMS,
                    Course  = chemistry
                }
                // studentWS not used
            };

            context.AddRange(enrollments);

            // Save changes
            context.SaveChanges();
        }
        public static void Initialize(SchoolContext context)
        {
            context.Database.EnsureCreated();

            // Look for any students.
            if (context.Students.Any())
            {
                return;   // DB has been seeded
            }

            var students = new Student[]
            {
                new Student {
                    FirstMidName = "Brown", LastName = "Ryan", EnrollmentDate = DateTime.Parse("2005-09-01")
                },
                new Student {
                    FirstMidName = "Wright", LastName = "Candace", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Wright", LastName = "Caitlin", EnrollmentDate = DateTime.Parse("2003-09-01")
                },
                new Student {
                    FirstMidName = "Wright", LastName = "Taylor", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Wright", LastName = "Madison", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Perez", LastName = "Serina", EnrollmentDate = DateTime.Parse("2001-09-01")
                },
                new Student {
                    FirstMidName = "Perez", LastName = "Natalie", EnrollmentDate = DateTime.Parse("2003-09-01")
                },
                new Student {
                    FirstMidName = "Brown", LastName = "Layla", EnrollmentDate = DateTime.Parse("2005-09-01")
                }
            };

            foreach (Student s in students)
            {
                context.Students.Add(s);
            }
            context.SaveChanges();

            var courses = new Course[]
            {
                new Course {
                    CourseID = 1050, Title = "Chemistry", Credits = 3
                },
                new Course {
                    CourseID = 4022, Title = "Microeconomics", Credits = 3
                },
                new Course {
                    CourseID = 4041, Title = "Macroeconomics", Credits = 3
                },
                new Course {
                    CourseID = 1045, Title = "Calculus", Credits = 4
                },
                new Course {
                    CourseID = 3141, Title = "Trigonometry", Credits = 4
                },
                new Course {
                    CourseID = 2021, Title = "Composition", Credits = 3
                },
                new Course {
                    CourseID = 2042, Title = "Literature", Credits = 4
                }
            };

            foreach (Course c in courses)
            {
                context.Courses.Add(c);
            }
            context.SaveChanges();

            var enrollments = new Enrollment[]
            {
                new Enrollment {
                    StudentID = 1, CourseID = 1050, Grade = Grade.A
                },
                new Enrollment {
                    StudentID = 1, CourseID = 4022, Grade = Grade.C
                },
                new Enrollment {
                    StudentID = 1, CourseID = 4041, Grade = Grade.B
                },
                new Enrollment {
                    StudentID = 2, CourseID = 1045, Grade = Grade.B
                },
                new Enrollment {
                    StudentID = 2, CourseID = 3141, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 2, CourseID = 2021, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 3, CourseID = 1050
                },
                new Enrollment {
                    StudentID = 4, CourseID = 1050
                },
                new Enrollment {
                    StudentID = 4, CourseID = 4022, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 5, CourseID = 4041, Grade = Grade.C
                },
                new Enrollment {
                    StudentID = 6, CourseID = 1045
                },
                new Enrollment {
                    StudentID = 7, CourseID = 3141, Grade = Grade.A
                },
            };

            foreach (Enrollment e in enrollments)
            {
                context.Enrollments.Add(e);
            }
            context.SaveChanges();
        }
Exemple #18
0
        public static void Initialize(SchoolContext context)
        {
            context.Database.EnsureCreated();

            // Look for any students.
            if (context.Students.Any())
            {
                return;   // DB has been seeded
            }

            // The code checks if there are any students in the database, and if not, it assumes the database is new
            // and needs to be seeded with test data.It loads test data into arrays rather than List<T> collections
            // to optimize performance.

            var students = new Student[]
            {
                new Student {
                    FirstMidName = "Carson", LastName = "Alexander", EnrollmentDate = DateTime.Parse("2005-09-01")
                },
                new Student {
                    FirstMidName = "Meredith", LastName = "Alonso", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Arturo", LastName = "Anand", EnrollmentDate = DateTime.Parse("2003-09-01")
                },
                new Student {
                    FirstMidName = "Gytis", LastName = "Barzdukas", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Yan", LastName = "Li", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Peggy", LastName = "Justice", EnrollmentDate = DateTime.Parse("2001-09-01")
                },
                new Student {
                    FirstMidName = "Laura", LastName = "Norman", EnrollmentDate = DateTime.Parse("2003-09-01")
                },
                new Student {
                    FirstMidName = "Nino", LastName = "Olivetto", EnrollmentDate = DateTime.Parse("2005-09-01")
                }
            };

            foreach (Student s in students)
            {
                context.Students.Add(s);
            }
            context.SaveChanges();

            var courses = new Course[]
            {
                new Course {
                    CourseID = 1050, Title = "Chemistry", Credits = 3
                },
                new Course {
                    CourseID = 4022, Title = "Microeconomics", Credits = 3
                },
                new Course {
                    CourseID = 4041, Title = "Macroeconomics", Credits = 3
                },
                new Course {
                    CourseID = 1045, Title = "Calculus", Credits = 4
                },
                new Course {
                    CourseID = 3141, Title = "Trigonometry", Credits = 4
                },
                new Course {
                    CourseID = 2021, Title = "Composition", Credits = 3
                },
                new Course {
                    CourseID = 2042, Title = "Literature", Credits = 4
                }
            };

            foreach (Course c in courses)
            {
                context.Courses.Add(c);
            }
            context.SaveChanges();

            var enrollments = new Enrollment[]
            {
                new Enrollment {
                    StudentID = 1, CourseID = 1050, Grade = Grade.A
                },
                new Enrollment {
                    StudentID = 1, CourseID = 4022, Grade = Grade.C
                },
                new Enrollment {
                    StudentID = 1, CourseID = 4041, Grade = Grade.B
                },
                new Enrollment {
                    StudentID = 2, CourseID = 1045, Grade = Grade.B
                },
                new Enrollment {
                    StudentID = 2, CourseID = 3141, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 2, CourseID = 2021, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 3, CourseID = 1050
                },
                new Enrollment {
                    StudentID = 4, CourseID = 1050
                },
                new Enrollment {
                    StudentID = 4, CourseID = 4022, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 5, CourseID = 4041, Grade = Grade.C
                },
                new Enrollment {
                    StudentID = 6, CourseID = 1045
                },
                new Enrollment {
                    StudentID = 7, CourseID = 3141, Grade = Grade.A
                },
            };

            foreach (Enrollment e in enrollments)
            {
                context.Enrollments.Add(e);
            }
            context.SaveChanges();
        }
Exemple #19
0
        public static void Initialize(SchoolContext context)
        {
            context.Database.EnsureCreated();

            // Look for any students.
            if (context.Students.Any())
            {
                return;   // DB has been seeded
            }

            var students = new Student[]
            {
                new Student {
                    FirstMidName   = "Joe", LastName = "Banana",
                    EnrollmentDate = DateTime.Parse("2010-01-01")
                },
                new Student {
                    FirstMidName   = "Sofia", LastName = "Berlin",
                    EnrollmentDate = DateTime.Parse("2012-01-01")
                },
                new Student {
                    FirstMidName   = "Silistra", LastName = "Busters",
                    EnrollmentDate = DateTime.Parse("2013-01-01")
                },
                new Student {
                    FirstMidName   = "Ivan", LastName = "B.",
                    EnrollmentDate = DateTime.Parse("2012-01-01")
                },
                new Student {
                    FirstMidName   = "Mina", LastName = "Batman",
                    EnrollmentDate = DateTime.Parse("2011-01-01")
                },
                new Student {
                    FirstMidName   = "Pesho", LastName = "Zorro",
                    EnrollmentDate = DateTime.Parse("2013-01-01")
                },
                new Student {
                    FirstMidName   = "Hristomir", LastName = "Hristov",
                    EnrollmentDate = DateTime.Parse("2005-01-01")
                }
            };

            foreach (Student s in students)
            {
                context.Students.Add(s);
            }
            context.SaveChanges();

            var instructors = new Instructor[]
            {
                new Instructor {
                    FirstMidName = "Krachun", LastName = "Malchov",
                    HireDate     = DateTime.Parse("1995-03-11")
                },
                new Instructor {
                    FirstMidName = "Safadi", LastName = "Yordanov",
                    HireDate     = DateTime.Parse("2002-07-06")
                },
                new Instructor {
                    FirstMidName = "Hristo", LastName = "Stoichkov",
                    HireDate     = DateTime.Parse("1998-07-01")
                },
                new Instructor {
                    FirstMidName = "Yordan", LastName = "Lechkov",
                    HireDate     = DateTime.Parse("2001-01-15")
                },
                new Instructor {
                    FirstMidName = "Hristo", LastName = "Zhabov",
                    HireDate     = DateTime.Parse("2004-02-12")
                }
            };

            foreach (Instructor i in instructors)
            {
                context.Instructors.Add(i);
            }
            context.SaveChanges();

            var departments = new Department[]
            {
                new Department {
                    Name         = "Advanced Design", Budget = 350000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorId = instructors.Single(i => i.LastName == "Malchov").Id
                },
                new Department {
                    Name         = "Design", Budget = 100000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorId = instructors.Single(i => i.LastName == "Yordanov").Id
                },
                new Department {
                    Name         = "Advanced Structures", Budget = 350000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorId = instructors.Single(i => i.LastName == "Stoichkov").Id
                },
                new Department {
                    Name         = "Advanced Programming", Budget = 100000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorId = instructors.Single(i => i.LastName == "Lechkov").Id
                }
            };

            foreach (Department d in departments)
            {
                context.Departments.Add(d);
            }
            context.SaveChanges();

            var courses = new Course[]
            {
                new Course {
                    CourseId     = 1050, Title = "General Programming", Credits = 3,
                    DepartmentId = departments.Single(s => s.Name == "Advanced Structures").DepartmentId
                },
                new Course {
                    CourseId     = 4022, Title = "Programming 101", Credits = 3,
                    DepartmentId = departments.Single(s => s.Name == "Advanced Programming").DepartmentId
                },
                new Course {
                    CourseId     = 4041, Title = "Programming 201", Credits = 3,
                    DepartmentId = departments.Single(s => s.Name == "Advanced Programming").DepartmentId
                },
                new Course {
                    CourseId     = 1045, Title = "Algorithms", Credits = 4,
                    DepartmentId = departments.Single(s => s.Name == "Design").DepartmentId
                },
                new Course {
                    CourseId     = 3141, Title = "Front End", Credits = 4,
                    DepartmentId = departments.Single(s => s.Name == "Design").DepartmentId
                },
                new Course {
                    CourseId     = 2021, Title = "Back End", Credits = 3,
                    DepartmentId = departments.Single(s => s.Name == "Advanced Design").DepartmentId
                },
                new Course {
                    CourseId     = 2042, Title = "CSS", Credits = 4,
                    DepartmentId = departments.Single(s => s.Name == "Advanced Design").DepartmentId
                },
            };

            foreach (Course c in courses)
            {
                context.Courses.Add(c);
            }
            context.SaveChanges();

            var officeAssignments = new OfficeAssignment[]
            {
                new OfficeAssignment {
                    InstructorId = instructors.Single(i => i.LastName == "Yordanov").Id,
                    Location     = "Nuremberg"
                },
                new OfficeAssignment {
                    InstructorId = instructors.Single(i => i.LastName == "Stoichkov").Id,
                    Location     = "Sofia"
                },
                new OfficeAssignment {
                    InstructorId = instructors.Single(i => i.LastName == "Lechkov").Id,
                    Location     = "Silistra"
                },
            };

            foreach (OfficeAssignment o in officeAssignments)
            {
                context.OfficeAssignments.Add(o);
            }
            context.SaveChanges();

            var courseInstructors = new CourseAssignment[]
            {
                new CourseAssignment {
                    CourseId     = courses.Single(c => c.Title == "General Programming").CourseId,
                    InstructorId = instructors.Single(i => i.LastName == "Lechkov").Id
                },
                new CourseAssignment {
                    CourseId     = courses.Single(c => c.Title == "General Programming").CourseId,
                    InstructorId = instructors.Single(i => i.LastName == "Stoichkov").Id
                },
                new CourseAssignment {
                    CourseId     = courses.Single(c => c.Title == "Programming 101").CourseId,
                    InstructorId = instructors.Single(i => i.LastName == "Zhabov").Id
                },
                new CourseAssignment {
                    CourseId     = courses.Single(c => c.Title == "Programming 201").CourseId,
                    InstructorId = instructors.Single(i => i.LastName == "Zhabov").Id
                },
                new CourseAssignment {
                    CourseId     = courses.Single(c => c.Title == "Algorithms").CourseId,
                    InstructorId = instructors.Single(i => i.LastName == "Yordanov").Id
                },
                new CourseAssignment {
                    CourseId     = courses.Single(c => c.Title == "Front End").CourseId,
                    InstructorId = instructors.Single(i => i.LastName == "Stoichkov").Id
                },
                new CourseAssignment {
                    CourseId     = courses.Single(c => c.Title == "Back End").CourseId,
                    InstructorId = instructors.Single(i => i.LastName == "Malchov").Id
                },
                new CourseAssignment {
                    CourseId     = courses.Single(c => c.Title == "CSS").CourseId,
                    InstructorId = instructors.Single(i => i.LastName == "Malchov").Id
                },
            };

            foreach (CourseAssignment ci in courseInstructors)
            {
                context.CourseAssignments.Add(ci);
            }
            context.SaveChanges();

            var enrollments = new Enrollment[]
            {
                new Enrollment {
                    StudentId = students.Single(s => s.LastName == "Banana").Id,
                    CourseId  = courses.Single(c => c.Title == "General Programming").CourseId,
                    Grade     = Grade.A
                },
                new Enrollment {
                    StudentId = students.Single(s => s.LastName == "Banana").Id,
                    CourseId  = courses.Single(c => c.Title == "Programming 101").CourseId,
                    Grade     = Grade.C
                },
                new Enrollment {
                    StudentId = students.Single(s => s.LastName == "Banana").Id,
                    CourseId  = courses.Single(c => c.Title == "Programming 201").CourseId,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentId = students.Single(s => s.LastName == "Berlin").Id,
                    CourseId  = courses.Single(c => c.Title == "Algorithms").CourseId,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentId = students.Single(s => s.LastName == "Berlin").Id,
                    CourseId  = courses.Single(c => c.Title == "Front End").CourseId,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentId = students.Single(s => s.LastName == "Berlin").Id,
                    CourseId  = courses.Single(c => c.Title == "Back End").CourseId,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentId = students.Single(s => s.LastName == "Busters").Id,
                    CourseId  = courses.Single(c => c.Title == "General Programming").CourseId
                },
                new Enrollment {
                    StudentId = students.Single(s => s.LastName == "Busters").Id,
                    CourseId  = courses.Single(c => c.Title == "Programming 101").CourseId,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentId = students.Single(s => s.LastName == "B.").Id,
                    CourseId  = courses.Single(c => c.Title == "General Programming").CourseId,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentId = students.Single(s => s.LastName == "Batman").Id,
                    CourseId  = courses.Single(c => c.Title == "CSS").CourseId,
                    Grade     = Grade.B
                }
            };

            foreach (Enrollment e in enrollments)
            {
                var enrollmentInDataBase = context.Enrollments.Where(
                    s =>
                    s.Student.Id == e.StudentId &&
                    s.Course.CourseId == e.CourseId).SingleOrDefault();
                if (enrollmentInDataBase == null)
                {
                    context.Enrollments.Add(e);
                }
            }
            context.SaveChanges();
        }
        public static void Initialize(SchoolContext context)
        {
            //context.Database.EnsureCreated();

            // Look for any students.
            if (context.Students.Any())
            {
                return;   // DB has been seeded
            }

            var students = new Student[]
            {
                new Student {
                    FirstMidName = "Sagnik", LastName = "Chatterjee", EnrollmentDate = DateTime.Parse("2019-09-01")
                },
                new Student {
                    FirstMidName = "Proloy", LastName = "Bhaduri", EnrollmentDate = DateTime.Parse("2017-09-01")
                },
                new Student {
                    FirstMidName = "Debmalya", LastName = "Dutta", EnrollmentDate = DateTime.Parse("2018-09-01")
                },
                new Student {
                    FirstMidName = "Rupam", LastName = "Sen", EnrollmentDate = DateTime.Parse("2017-09-01")
                },
                new Student {
                    FirstMidName = "Darshan", LastName = "Sen", EnrollmentDate = DateTime.Parse("2017-09-01")
                },
                new Student {
                    FirstMidName = "Sandipan", LastName = "Bera", EnrollmentDate = DateTime.Parse("2016-09-01")
                },
                new Student {
                    FirstMidName = "Sayak", LastName = "Chakroborty", EnrollmentDate = DateTime.Parse("2018-09-01")
                },
                new Student {
                    FirstMidName = "Soumyajit", LastName = "Bera", EnrollmentDate = DateTime.Parse("2019-09-01")
                }
            };

            context.Students.AddRange(students);
            context.SaveChanges();

            var instructors = new Instructor[]
            {
                new Instructor {
                    FirstMidName = "Kim", LastName = "Abercrombie",
                    HireDate     = DateTime.Parse("1995-03-11")
                },
                new Instructor {
                    FirstMidName = "Fadi", LastName = "Fakhouri",
                    HireDate     = DateTime.Parse("2002-07-06")
                },
                new Instructor {
                    FirstMidName = "Roger", LastName = "Harui",
                    HireDate     = DateTime.Parse("1998-07-01")
                },
                new Instructor {
                    FirstMidName = "Candace", LastName = "Kapoor",
                    HireDate     = DateTime.Parse("2001-01-15")
                },
                new Instructor {
                    FirstMidName = "Roger", LastName = "Zheng",
                    HireDate     = DateTime.Parse("2004-02-12")
                }
            };

            context.Instructors.AddRange(instructors);
            context.SaveChanges();

            var departments = new Department[]
            {
                new Department {
                    Name         = "English", Budget = 350000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Abercrombie").ID
                },
                new Department {
                    Name         = "Mathematics", Budget = 100000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Fakhouri").ID
                },
                new Department {
                    Name         = "Engineering", Budget = 350000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Harui").ID
                },
                new Department {
                    Name         = "Economics", Budget = 100000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Kapoor").ID
                }
            };

            context.Departments.AddRange(departments);
            context.SaveChanges();

            var courses = new Course[]
            {
                new Course {
                    CourseID = 1050, Title = "Chemistry", Credits = 3
                },
                new Course {
                    CourseID = 4022, Title = "Microeconomics", Credits = 3
                },
                new Course {
                    CourseID = 4041, Title = "Macroeconomics", Credits = 3
                },
                new Course {
                    CourseID = 1045, Title = "Calculus", Credits = 4
                },
                new Course {
                    CourseID = 3141, Title = "Trigonometry", Credits = 4
                },
                new Course {
                    CourseID = 2021, Title = "Composition", Credits = 3
                },
                new Course {
                    CourseID = 2042, Title = "Literature", Credits = 4
                }
            };

            context.Courses.AddRange(courses);
            context.SaveChanges();

            var officeAssignments = new OfficeAssignment[]
            {
                new OfficeAssignment {
                    InstructorID = instructors.Single(i => i.LastName == "Fakhouri").ID,
                    Location     = "Smith 17"
                },
                new OfficeAssignment {
                    InstructorID = instructors.Single(i => i.LastName == "Harui").ID,
                    Location     = "Gowan 27"
                },
                new OfficeAssignment {
                    InstructorID = instructors.Single(i => i.LastName == "Kapoor").ID,
                    Location     = "Thompson 304"
                },
            };

            context.OfficeAssignments.AddRange(officeAssignments);
            context.SaveChanges();

            var courseInstructors = new CourseAssignment[]
            {
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Chemistry").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Kapoor").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Chemistry").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Harui").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Microeconomics").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Zheng").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Macroeconomics").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Zheng").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Calculus").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Fakhouri").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Trigonometry").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Harui").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Composition").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Abercrombie").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Literature").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Abercrombie").ID
                },
            };

            context.CourseAssignments.AddRange(courseInstructors);
            context.SaveChanges();

            var enrollments = new Enrollment[]
            {
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Alexander").ID,
                    CourseID  = courses.Single(c => c.Title == "Chemistry").CourseID,
                    Grade     = Grade.A
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Alexander").ID,
                    CourseID  = courses.Single(c => c.Title == "Microeconomics").CourseID,
                    Grade     = Grade.C
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Alexander").ID,
                    CourseID  = courses.Single(c => c.Title == "Macroeconomics").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Alonso").ID,
                    CourseID  = courses.Single(c => c.Title == "Calculus").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Alonso").ID,
                    CourseID  = courses.Single(c => c.Title == "Trigonometry").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Alonso").ID,
                    CourseID  = courses.Single(c => c.Title == "Composition").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Anand").ID,
                    CourseID  = courses.Single(c => c.Title == "Chemistry").CourseID
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Anand").ID,
                    CourseID  = courses.Single(c => c.Title == "Microeconomics").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Barzdukas").ID,
                    CourseID  = courses.Single(c => c.Title == "Chemistry").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Li").ID,
                    CourseID  = courses.Single(c => c.Title == "Composition").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Justice").ID,
                    CourseID  = courses.Single(c => c.Title == "Literature").CourseID,
                    Grade     = Grade.B
                }
            };

            foreach (Enrollment e in enrollments)
            {
                var enrollmentInDataBase = context.Enrollments.Where(
                    s =>
                    s.Student.ID == e.StudentID &&
                    s.Course.CourseID == e.CourseID).SingleOrDefault();
                if (enrollmentInDataBase == null)
                {
                    context.Enrollments.Add(e);
                }
            }
            context.SaveChanges();
        }
Exemple #21
0
        public static void Initialize(SchoolContext context)
        {
            context.Database.EnsureCreated();

            //(Would get an error message if I don't add these beforehand) <!-- //tinfo200:[2021-03-10-rmatta2-dykstra1] - To view students.-->
            if (context.Students.Any())
            {
                return;   //(Would get an error message if I don't add these beforehand) <!-- //tinfo200:[2021-03-10-rmatta2-dykstra1] - Add DB for code.-->
            }

            var students = new Student[]
            {
                new Student {
                    FirstMidName = "Carson", LastName = "Alexander", EnrollmentDate = DateTime.Parse("2005-09-01")
                },
                new Student {
                    FirstMidName = "Meredith", LastName = "Alonso", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Arturo", LastName = "Anand", EnrollmentDate = DateTime.Parse("2003-09-01")
                },
                new Student {
                    FirstMidName = "Gytis", LastName = "Barzdukas", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Yan", LastName = "Li", EnrollmentDate = DateTime.Parse("2002-09-01")
                },
                new Student {
                    FirstMidName = "Peggy", LastName = "Justice", EnrollmentDate = DateTime.Parse("2001-09-01")
                },
                new Student {
                    FirstMidName = "Laura", LastName = "Norman", EnrollmentDate = DateTime.Parse("2003-09-01")
                },
                new Student {
                    FirstMidName = "Nino", LastName = "Olivetto", EnrollmentDate = DateTime.Parse("2005-09-01")
                }                                                                                            //(Would get an error message if I don't add these beforehand) <!-- //tinfo200:[2021-03-10-rmatta2-dykstra1] - Add info for code.-->
            };

            foreach (Student s in students)
            {
                context.Students.Add(s);
            }
            context.SaveChanges();

            var courses = new Course[]
            {
                new Course {
                    CourseID = 1050, Title = "Chemistry", Credits = 3
                },
                new Course {
                    CourseID = 4022, Title = "Microeconomics", Credits = 3
                },
                new Course {
                    CourseID = 4041, Title = "Macroeconomics", Credits = 3
                },
                new Course {
                    CourseID = 1045, Title = "Calculus", Credits = 4
                },
                new Course {
                    CourseID = 3141, Title = "Trigonometry", Credits = 4
                },
                new Course {
                    CourseID = 2021, Title = "Composition", Credits = 3
                },
                new Course {
                    CourseID = 2042, Title = "Literature", Credits = 4
                }                                                  //(Would get an error message if I don't add these beforehand) <!-- //tinfo200:[2021-03-10-rmatta2-dykstra1] - Add info for code.-->
            };

            foreach (Course c in courses)
            {
                context.Courses.Add(c);
            }
            context.SaveChanges();

            var enrollments = new Enrollment[]
            {
                new Enrollment {
                    StudentID = 1, CourseID = 1050, Grade = Grade.A
                },
                new Enrollment {
                    StudentID = 1, CourseID = 4022, Grade = Grade.C
                },
                new Enrollment {
                    StudentID = 1, CourseID = 4041, Grade = Grade.B
                },
                new Enrollment {
                    StudentID = 2, CourseID = 1045, Grade = Grade.B
                },
                new Enrollment {
                    StudentID = 2, CourseID = 3141, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 2, CourseID = 2021, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 3, CourseID = 1050
                },
                new Enrollment {
                    StudentID = 4, CourseID = 1050
                },
                new Enrollment {
                    StudentID = 4, CourseID = 4022, Grade = Grade.F
                },
                new Enrollment {
                    StudentID = 5, CourseID = 4041, Grade = Grade.C
                },
                new Enrollment {
                    StudentID = 6, CourseID = 1045
                },
                new Enrollment {
                    StudentID = 7, CourseID = 3141, Grade = Grade.A
                },                                                   //(Would get an error message if I don't add these beforehand) <!-- //tinfo200:[2021-03-10-rmatta2-dykstra1] - Add info for code.-->
            };

            foreach (Enrollment e in enrollments)
            {
                context.Enrollments.Add(e);
            }
            context.SaveChanges();
        }
Exemple #22
0
        public static void Initialize(SchoolContext context)
        {
            context.Database.EnsureCreated();

            if (context.Students.Any())
            {
                return;
            }

            var students = new Student[]
            {
                new Student {
                    FirstMidName = "Carlson", LastName = "On the Roof", EnrollmentDate = DateTime.Parse("2000-01-01")
                },
                new Student {
                    FirstMidName = "Mike", LastName = "Green", EnrollmentDate = DateTime.Parse("2001-01-01")
                },
                new Student {
                    FirstMidName = "Jack", LastName = "Red", EnrollmentDate = DateTime.Parse("2002-01-01")
                },
                new Student {
                    FirstMidName = "Jill", LastName = "Purple", EnrollmentDate = DateTime.Parse("2003-01-01")
                },
            };

            foreach (Student s in students)
            {
                context.Students.Add(s);
            }

            var courses = new Course[]
            {
                new Course {
                    CourseId = 711, Title = "VBA", Credits = 3
                },
                new Course {
                    CourseId = 712, Title = "VBA102", Credits = 4
                },
                new Course {
                    CourseId = 713, Title = "VB.NET", Credits = 3
                },
                new Course {
                    CourseId = 714, Title = "C++", Credits = 3
                },
            };

            foreach (Course c in courses)
            {
                context.Courses.Add(c);
            }

            var enrollments = new Enrollment[]
            {
                new Enrollment {
                    StudentId = 1, CourseId = 711, Grade = Grade.A
                },
                new Enrollment {
                    StudentId = 1, CourseId = 712, Grade = Grade.A
                },
                new Enrollment {
                    StudentId = 1, CourseId = 713, Grade = Grade.B
                },
                new Enrollment {
                    StudentId = 2, CourseId = 711, Grade = Grade.C
                },
                new Enrollment {
                    StudentId = 2, CourseId = 712
                },
                new Enrollment {
                    StudentId = 3, CourseId = 711
                },
                new Enrollment {
                    StudentId = 3, CourseId = 712, Grade = Grade.B
                },
            };

            foreach (Enrollment e in enrollments)
            {
                context.Enrollments.Add(e);
            }
            context.SaveChanges();
        }
Exemple #23
0
        public static void Initialize(SchoolContext context)
        {
            context.Database.EnsureCreated();

            // Look for any students.
            if (context.Departments.Any())
            {
                return;   // DB has been seeded
            }

            var students = new Student[]
            {
                new Student {
                    FirstMidName   = "Carson", LastName = "Alexander",
                    EnrollmentDate = DateTime.Parse("2010-09-01")
                },
                new Student {
                    FirstMidName   = "Meredith", LastName = "Alonso",
                    EnrollmentDate = DateTime.Parse("2012-09-01")
                },
                new Student {
                    FirstMidName   = "Arturo", LastName = "Anand",
                    EnrollmentDate = DateTime.Parse("2013-09-01")
                },
                new Student {
                    FirstMidName   = "Gytis", LastName = "Barzdukas",
                    EnrollmentDate = DateTime.Parse("2012-09-01")
                },
                new Student {
                    FirstMidName   = "Yan", LastName = "Li",
                    EnrollmentDate = DateTime.Parse("2012-09-01")
                },
                new Student {
                    FirstMidName   = "Peggy", LastName = "Justice",
                    EnrollmentDate = DateTime.Parse("2011-09-01")
                },
                new Student {
                    FirstMidName   = "Laura", LastName = "Norman",
                    EnrollmentDate = DateTime.Parse("2013-09-01")
                },
                new Student {
                    FirstMidName   = "Nino", LastName = "Olivetto",
                    EnrollmentDate = DateTime.Parse("2005-09-01")
                }
            };

            foreach (Student s in students)
            {
                context.Students.Add(s);
            }
            context.SaveChanges();

            var instructors = new Instructor[]
            {
                new Instructor {
                    FirstMidName = "Kim", LastName = "Abercrombie",
                    HireDate     = DateTime.Parse("1995-03-11")
                },
                new Instructor {
                    FirstMidName = "Fadi", LastName = "Fakhouri",
                    HireDate     = DateTime.Parse("2002-07-06")
                },
                new Instructor {
                    FirstMidName = "Roger", LastName = "Harui",
                    HireDate     = DateTime.Parse("1998-07-01")
                },
                new Instructor {
                    FirstMidName = "Candace", LastName = "Kapoor",
                    HireDate     = DateTime.Parse("2001-01-15")
                },
                new Instructor {
                    FirstMidName = "Roger", LastName = "Zheng",
                    HireDate     = DateTime.Parse("2004-02-12")
                }
            };

            foreach (Instructor i in instructors)
            {
                context.Instructors.Add(i);
            }
            context.SaveChanges();

            var departments = new Department[]
            {
                new Department {
                    Name         = "English", Budget = 350000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Abercrombie").ID,
                },
                new Department {
                    Name         = "Mathematics", Budget = 100000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Fakhouri").ID
                },
                new Department {
                    Name         = "Engineering", Budget = 350000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Harui").ID
                },
                new Department {
                    Name         = "Economics", Budget = 100000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Kapoor").ID
                }
            };

            foreach (Department d in departments)
            {
                context.Departments.Add(d);
            }
            context.SaveChanges();

            var courses = new Course[]
            {
                new Course {
                    CourseID     = 1050, Title = "Chemistry", Credits = 3,
                    DepartmentID = departments.Single(s => s.Name == "Engineering").DepartmentID
                },
                new Course {
                    CourseID     = 4022, Title = "Microeconomics", Credits = 3,
                    DepartmentID = departments.Single(s => s.Name == "Economics").DepartmentID
                },
                new Course {
                    CourseID     = 4041, Title = "Macroeconomics", Credits = 3,
                    DepartmentID = departments.Single(s => s.Name == "Economics").DepartmentID
                },
                new Course {
                    CourseID     = 1045, Title = "Calculus", Credits = 4,
                    DepartmentID = departments.Single(s => s.Name == "Mathematics").DepartmentID
                },
                new Course {
                    CourseID     = 3141, Title = "Trigonometry", Credits = 4,
                    DepartmentID = departments.Single(s => s.Name == "Mathematics").DepartmentID
                },
                new Course {
                    CourseID     = 2021, Title = "Composition", Credits = 3,
                    DepartmentID = departments.Single(s => s.Name == "English").DepartmentID
                },
                new Course {
                    CourseID     = 2042, Title = "Literature", Credits = 4,
                    DepartmentID = departments.Single(s => s.Name == "English").DepartmentID
                },
            };

            foreach (Course c in courses)
            {
                context.Courses.Add(c);
            }
            context.SaveChanges();

            var officeAssignments = new OfficeAssignment[]
            {
                new OfficeAssignment {
                    InstructorID = instructors.Single(i => i.LastName == "Fakhouri").ID,
                    Location     = "Smith 17"
                },
                new OfficeAssignment {
                    InstructorID = instructors.Single(i => i.LastName == "Harui").ID,
                    Location     = "Gowan 27"
                },
                new OfficeAssignment {
                    InstructorID = instructors.Single(i => i.LastName == "Kapoor").ID,
                    Location     = "Thompson 304"
                },
            };

            foreach (OfficeAssignment o in officeAssignments)
            {
                context.OfficeAssignments.Add(o);
            }
            context.SaveChanges();

            var courseInstructors = new CourseAssignment[]
            {
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Chemistry").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Kapoor").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Chemistry").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Harui").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Microeconomics").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Zheng").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Macroeconomics").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Zheng").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Calculus").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Fakhouri").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Trigonometry").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Harui").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Composition").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Abercrombie").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Literature").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Abercrombie").ID
                },
            };

            foreach (CourseAssignment ci in courseInstructors)
            {
                context.CourseAssignments.Add(ci);
            }
            context.SaveChanges();

            var enrollments = new Enrollment[]
            {
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Alexander").ID,
                    CourseID  = courses.Single(c => c.Title == "Chemistry").CourseID,
                    Grade     = Grade.A
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Alexander").ID,
                    CourseID  = courses.Single(c => c.Title == "Microeconomics").CourseID,
                    Grade     = Grade.C
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Alexander").ID,
                    CourseID  = courses.Single(c => c.Title == "Macroeconomics").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Alonso").ID,
                    CourseID  = courses.Single(c => c.Title == "Calculus").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Alonso").ID,
                    CourseID  = courses.Single(c => c.Title == "Trigonometry").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Alonso").ID,
                    CourseID  = courses.Single(c => c.Title == "Composition").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Anand").ID,
                    CourseID  = courses.Single(c => c.Title == "Chemistry").CourseID
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Anand").ID,
                    CourseID  = courses.Single(c => c.Title == "Microeconomics").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Barzdukas").ID,
                    CourseID  = courses.Single(c => c.Title == "Chemistry").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Li").ID,
                    CourseID  = courses.Single(c => c.Title == "Composition").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Justice").ID,
                    CourseID  = courses.Single(c => c.Title == "Literature").CourseID,
                    Grade     = Grade.B
                }
            };

            foreach (Enrollment e in enrollments)
            {
                var enrollmentInDataBase = context.Enrollments.Where(
                    s =>
                    s.Student.ID == e.StudentID &&
                    s.Course.CourseID == e.CourseID).SingleOrDefault();
                if (enrollmentInDataBase == null)
                {
                    context.Enrollments.Add(e);
                }
            }
            context.SaveChanges();
        }
        public static void Initialize(SchoolContext context)
        {
            //context.Database.EnsureCreated();

            // Look for any students.
            if (context.Students.Any())
            {
                return;   // DB has been seeded
            }

            var students = new Student[]
            {
                new Student
                {
                    FirstMidName = "Mark Matteus", LastName = "Murru", EnrollmentDate = DateTime.Parse("2019-08.20")
                },
                new Student
                {
                    FirstMidName = "Madli", LastName = "Kaevats", EnrollmentDate = DateTime.Parse("2019-08.20")
                },
                new Student {
                    FirstMidName = "Hugo", LastName = "Valk", EnrollmentDate = DateTime.Parse("2019-08.20")
                },
                new Student
                {
                    FirstMidName = "Johann", LastName = "Kuldmäe", EnrollmentDate = DateTime.Parse("2017-08.20")
                },
                new Student {
                    FirstMidName = "Elise", LastName = "Lomp", EnrollmentDate = DateTime.Parse("2019-08.20")
                },
                new Student {
                    FirstMidName = "Toru", LastName = "Jüri", EnrollmentDate = DateTime.Parse("2012-04.12")
                },
                new Student {
                    FirstMidName = "Sammal", LastName = "Habe", EnrollmentDate = DateTime.Parse("2013-03.14")
                },
                new Student {
                    FirstMidName = "Nipi", LastName = "Tiri", EnrollmentDate = DateTime.Parse("2010-02.18")
                }
            };

            foreach (Student s in students)
            {
                context.Students.Add(s);
            }
            context.SaveChanges();
            var instructors = new Instructor[]
            {
                new Instructor {
                    FirstMidName = "Kim", LastName = "Abercrombie",
                    HireDate     = DateTime.Parse("1995-03-11")
                },
                new Instructor {
                    FirstMidName = "Fadi", LastName = "Fakhouri",
                    HireDate     = DateTime.Parse("2002-07-06")
                },
                new Instructor {
                    FirstMidName = "Roger", LastName = "Harui",
                    HireDate     = DateTime.Parse("1998-07-01")
                },
                new Instructor {
                    FirstMidName = "Candace", LastName = "Kapoor",
                    HireDate     = DateTime.Parse("2001-01-15")
                },
                new Instructor {
                    FirstMidName = "Roger", LastName = "Zheng",
                    HireDate     = DateTime.Parse("2004-02-12")
                }
            };

            foreach (Instructor i in instructors)
            {
                context.Instructors.Add(i);
            }
            context.SaveChanges();
            var departments = new Department[]
            {
                new Department {
                    Name         = "Information Technology", Budget = 350000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Abercrombie").ID
                },
                new Department {
                    Name         = "Mathematics", Budget = 100000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Fakhouri").ID
                },
                new Department {
                    Name         = "Engineering", Budget = 350000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Harui").ID
                },
                new Department {
                    Name         = "Economics", Budget = 100000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Kapoor").ID
                }
            };

            foreach (Department d in departments)
            {
                context.Departments.Add(d);
            }
            context.SaveChanges();
            var courses = new Course[]
            {
                new Course {
                    CourseID = 1702, Title = "Web Applications", Credits = 12, DepartmentID = departments.Single(s => s.Name == "Information Technology").DepartmentID
                },
                new Course {
                    CourseID = 0150, Title = "Economics", Credits = 6, DepartmentID = departments.Single(s => s.Name == "Economics").DepartmentID
                },
                new Course {
                    CourseID = 1615, Title = "Data Processing", Credits = 6, DepartmentID = departments.Single(s => s.Name == "Mathematics").DepartmentID
                },
                new Course {
                    CourseID = 1708, Title = "IT Operations", Credits = 6, DepartmentID = departments.Single(s => s.Name == "Information Technology").DepartmentID
                },
                new Course {
                    CourseID = 0153, Title = "Accounting", Credits = 6, DepartmentID = departments.Single(s => s.Name == "Economics").DepartmentID
                },
                new Course {
                    CourseID = 1618, Title = "Calculus", Credits = 6, DepartmentID = departments.Single(s => s.Name == "Mathematics").DepartmentID
                }
            };

            foreach (Course c in courses)
            {
                context.Courses.Add(c);
            }
            context.SaveChanges();
            var officeAssignments = new OfficeAssignment[]
            {
                new OfficeAssignment {
                    InstructorID = instructors.Single(i => i.LastName == "Fakhouri").ID,
                    Location     = "Smith 17"
                },
                new OfficeAssignment {
                    InstructorID = instructors.Single(i => i.LastName == "Harui").ID,
                    Location     = "Gowan 27"
                },
                new OfficeAssignment {
                    InstructorID = instructors.Single(i => i.LastName == "Kapoor").ID,
                    Location     = "Thompson 304"
                },
            };

            foreach (OfficeAssignment o in officeAssignments)
            {
                context.OfficeAssignments.Add(o);
            }
            context.SaveChanges();
            var courseInstructors = new CourseAssignment[]
            {
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Web Applications").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Kapoor").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Web Applications").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Harui").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Calculus").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Zheng").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Economics").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Zheng").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Calculus").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Fakhouri").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "IT Operations").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Harui").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Data Processing").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Abercrombie").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Economics").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Abercrombie").ID
                },
            };

            foreach (CourseAssignment ci in courseInstructors)
            {
                context.CourseAssignments.Add(ci);
            }
            context.SaveChanges();

            var enrollments = new Enrollment[]
            {
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Valk").ID,
                    CourseID  = courses.Single(c => c.Title == "Economics").CourseID,
                    Grade     = Grade.A
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Lomp").ID,
                    CourseID  = courses.Single(c => c.Title == "Web Applications").CourseID,
                    Grade     = Grade.C
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Kuldmäe").ID,
                    CourseID  = courses.Single(c => c.Title == "Web Applications").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Kaevats").ID,
                    CourseID  = courses.Single(c => c.Title == "Calculus").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Kaevats").ID,
                    CourseID  = courses.Single(c => c.Title == "Data Processing").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Murru").ID,
                    CourseID  = courses.Single(c => c.Title == "IT Operations").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Tiri").ID,
                    CourseID  = courses.Single(c => c.Title == "IT Operations").CourseID
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Habe").ID,
                    CourseID  = courses.Single(c => c.Title == "Economics").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Habe").ID,
                    CourseID  = courses.Single(c => c.Title == "Data Processing").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Valk").ID,
                    CourseID  = courses.Single(c => c.Title == "Web Applications").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Murru").ID,
                    CourseID  = courses.Single(c => c.Title == "Web Applications").CourseID,
                    Grade     = Grade.B
                }
            };

            foreach (Enrollment e in enrollments)
            {
                var enrollmentInDataBase = context.Enrollments.Where(
                    s =>
                    s.Student.ID == e.StudentID &&
                    s.Course.CourseID == e.CourseID).SingleOrDefault();
                if (enrollmentInDataBase == null)
                {
                    context.Enrollments.Add(e);
                }
            }
            context.SaveChanges();
        }