コード例 #1
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new ProfessorDbContext(
                       serviceProvider.GetService <
                           DbContextOptions <ProfessorDbContext> >()))
            {
                if (context.Professor.Any())
                {
                    return;
                }

                context.Professor.AddRange(
                    new Professor
                {
                    FirstName = "Kareem",
                    LastName  = "Dana"
                },
                    new Professor
                {
                    FirstName = "Jeffery",
                    LastName  = "Babb"
                },
                    new Professor
                {
                    FirstName = "Amjad",
                    LastName  = "Abdallat"
                }
                    );
                context.SaveChanges();
            }
        }
コード例 #2
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new ProfessorDbContext(serviceProvider.GetRequiredService <DbContextOptions <ProfessorDbContext> >()))
            {
                // Look for any blogs.
                if (context.Professor.Any())
                {
                    return; // DB has been seeded
                }

                context.Professor.AddRange(
                    new Professor
                {
                    FirstName = "Kareem",
                    LastName  = "Dana",
                    Courses   = new List <Course> {
                        new Course {
                            Description = "CIDM3312"
                        },
                        new Course {
                            Description = "CIDM4360"
                        },
                    }
                },
                    new Professor
                {
                    FirstName = "Nesrin",
                    LastName  = "Bakir",
                }
                    );

                context.SaveChanges();
            }
        }
コード例 #3
0
 public IndexModel(Lab11.Models.ProfessorDbContext context)
 {
     _context = context;
 }