Esempio n. 1
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new MvcStudentContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <MvcStudentContext> >()))
            {
                // Look for any Students. If there are any students in DB, no new rows are added.
                if (context.Student.Any())
                {
                    return;   // DB has been seeded
                }

                context.Student.AddRange(
                    new Student
                {
                    Name   = "Harry",
                    Rating = "A",
                    Age    = 12
                },

                    new Student
                {
                    Name   = "Lenny",
                    Rating = "C",
                    Age    = 13
                },

                    new Student
                {
                    Name   = "Barry",
                    Rating = "A",
                    Age    = 15
                },

                    new Student
                {
                    Name   = "Haarry",
                    Rating = "B",
                    Age    = 17
                }
                    );
                context.SaveChanges();
            }
        }
Esempio n. 2
0
 public TutorsController(MvcStudentContext context)
 {
     _context = context;
 }
Esempio n. 3
0
 public BranchesController(MvcStudentContext context)
 {
     _context = context;
 }