Esempio n. 1
0
        static void Main(string[] args)
        {
            using (var db = new StudentContext())
            {
                var student = new Student()
                {
                    Name = "Corey DeRosa"
                };

                var mathSub = new Subject()
                {
                    Name = "Math"
                };
                var progSub = new Subject()
                {
                    Name = "Programming"
                };

                student.Subjects.Add(mathSub);
                student.Subjects.Add(progSub);

                db.Students.Add(student);
                db.SaveChanges();
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            using (var db = new StudentContext())
            {
                var student = new Student()
                {
                    Name = "Shimi"
                };
                var mathSubj = new Subject()
                {
                    Name = "Mathematics"
                };
                var scienceSubj = new Subject()
                {
                    Name = "Data Structures"
                };

                student.Subjects.Add(mathSubj);
                student.Subjects.Add(scienceSubj);

                db.Students.Add(student);
                db.SaveChanges();
                /////////////////
//test
            }
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            using (var db = new StudentContext())
            {
                var student = new Student() {Name = "Fabio Scapel"};
                var mathSubject = new Subject() {Name = "math"};
                var scienceSubj = new Subject() {Name = "Data Structures"};

                student.Subjects.Add(mathSubject);
                student.Subjects.Add(scienceSubj);

                db.Students.Add(student);
                db.SaveChanges();

            }
        }