Exemplo n.º 1
0
        static void Main(string[] args)
        {

            using (var ctx = new School())
            {
                Student student = new Student() {StudentName = "Ove Pollsen", BirthDate = DateTime.Now.AddYears(-30)};

                ctx.Students.Add(student);
                ctx.SaveChanges();
            }
            Console.ReadLine();
        }
Exemplo n.º 2
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();

            }
        }