예제 #1
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new CodingTestDbContext(
                       serviceProvider.GetRequiredService <DbContextOptions <CodingTestDbContext> >()))
            {
                // Look for any Categories.
                if (context.Categories.Any())
                {
                    return;
                }

                context.Categories.AddRange(
                    new Category
                {
                    CategoryId   = 1,
                    CategoryName = "Government"
                },
                    new Category
                {
                    CategoryId   = 2,
                    CategoryName = "Corporate Customer"
                },
                    new Category
                {
                    CategoryId   = 3,
                    CategoryName = "Individual"
                });

                context.SaveChanges();
            }
        }
예제 #2
0
 public CustomerService(CodingTestDbContext dbContext)
 {
     _dbContext = dbContext;
 }