public static bool CreateEmployee(EvolutionRepository.Models.Employee CreateEmp) { var Result = false; try { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { if (Object.Equals(null, ctx.Employees.FirstOrDefault(x => x.EmployeeID == CreateEmp.EmployeeID))) { ctx.Employees.Add(CreateEmp); ctx.SaveChanges(); } Result = true; } } catch (DbEntityValidationException ex) { // Throw a new DbEntityValidationException with the improved exception message. throw new DbEntityValidationException(ErrorHandler.BuildDbEntityValidationErrorMessage(ex), ex.EntityValidationErrors); } catch (Exception ex) { Result = false; throw ex; } return(Result); }