Example #1
0
 public void F_Relations()
 {
     using (var context = new SamplesContext())
     {
         var lesson = new Lesson
         {
             Id             = 19,
             Date           = new DateTime(2018, 9, 10),
             Name           = "ADO NET",
             LessonTeachers = new List <LessonTeacher>
             {
                 new LessonTeacher
                 {
                     Teacher = new Teacher
                     {
                         Id   = 3,
                         Name = "Igor Pavlovskiy"
                     }
                 }
             }
         };
         context.Add(lesson);
         context.SaveChanges();
     }
 }
Example #2
0
        public void C_Add()
        {
            using (var context = new SamplesContext())
            {
                context.Add(new Lesson {
                    Id = 21, Date = new DateTime(2018, 9, 13), Name = "Net Core"
                });
                context.Add(new Lesson {
                    Id = 22, Date = new DateTime(2018, 9, 17), Name = "Entity Framework"
                });
                context.Add(new Lesson {
                    Id = 23, Date = new DateTime(2018, 9, 20), Name = "Web API"
                });
                context.Add(new Lesson {
                    Id = 24, Date = new DateTime(2018, 9, 24), Name = "Elasticsearch/Redis"
                });
                context.Add(new Lesson {
                    Id = 25, Date = new DateTime(2018, 9, 28), Name = "Docker"
                });
                context.Add(new Lesson {
                    Id = 26, Date = new DateTime(2018, 10, 1), Name = "Cloud"
                });
                context.Add(new Lesson {
                    Id = 27, Date = new DateTime(2018, 10, 4), Name = "Cloud"
                });
                context.Add(new Lesson {
                    Id   = 28, Date = new DateTime(2018, 10, 5),
                    Name = "How to become a millionaire"
                });

                context.Teachers.Add(new Teacher {
                    Name = "Aleksandr Kugushev"
                });
                context.Teachers.Add(new Teacher {
                    Name = "Natalia Tcvilikh"
                });

                context.SaveChanges();
            }
        }