public void UploadEmployees(List<Employee> employees)
{
SalesERPDAL salesDal = new SalesERPDAL();
foreach (Employee emp in employees)
{
salesDal.Employees.Add(emp);
salesDal.Configuration.ValidateOnSaveEnabled = false;//增加这就就ok了
salesDal.SaveChanges();
}
}
由于用的是MVC4 ,不支持这样写
public void UploadEmployees(List<Employee> employees)
{
SalesERPDAL salesDal = new SalesERPDAL();
salesDal.Employees.AddRange(employees);
salesDal.SaveChanges();
}