static void Seed(SampleCoreDbContext context)
 {
     if (!context.Department.Any())
     {
         context.Department.AddRange(new List <Department>()
         {
             new Department()
             {
                 DepartmentName = "Test1Dept",
                 IsActive       = false
             },
             new Department()
             {
                 DepartmentName = "Test12Dept",
                 IsActive       = false
             },
             new Department()
             {
                 DepartmentName = "Test13Dept",
                 IsActive       = false
             }
         });
         context.SaveChanges();
     }
 }
Ejemplo n.º 2
0
        public void InsertDept(Department department)
        {
            //using (SampleCoreDbContext dbContext = new SampleCoreDbContext())
            //{
            //    dbContext.Department.Add(department);
            //    dbContext.SaveChanges();
            //}

            try
            {
                _dbContext.Department.Add(department);
                _dbContext.SaveChanges();
            }
            catch (DbUpdateException)
            {
                throw;
            }
        }