Exemplo n.º 1
0
        // also calling seed data in the configure method of startup.cs

        public static void InitializeDb(IServiceProvider serviceProvider)
        {
            using (var context = new JobBoardDbContext(
                       serviceProvider.GetRequiredService <DbContextOptions <JobBoardDbContext> >()))
            {
                if (context.JsonJob.Any())
                {
                    return; // db has already been seeded
                }

                context.JsonJob.AddRange(
                    new JsonJob
                {
                    ApplicationLink = "http://www.phcnw.com/about-us/careers-phcnw",
                    Company         = "PHC Northwest",
                    DatePosted      = "Closing Date: open until filled",
                    Experience      = "",
                    Hours           = "Full Time",
                    JobID           = "",
                    JobTitle        = "Project Area Manager, Washington County",
                    LanguagesUsed   = "",
                    Location        = "Portland Metro",
                    Salary          = ""
                },

                    new JsonJob
                {
                    ApplicationLink = "http://[email protected]",
                    Company         = "Maxwell PR + Engagement",
                    DatePosted      = "Closing Date: open until filled",
                    Experience      = "",
                    Hours           = "Full Time",
                    JobID           = "",
                    JobTitle        = "Paid Media Specialist",
                    LanguagesUsed   = "",
                    Location        = "Portland Metro",
                    Salary          = ""
                }
                    );

                // save the data into the db
                context.SaveChanges();
            }
        }