public int Upsert(Employee employee)
{
using (var context = new CodeFirstModels())
{
if (employee.EmployeeKey == 0)
context.Entry(employee).State = EntityState.Added;
else
context.Entry(employee).State = EntityState.Modified;
context.SaveChanges();
return employee.EmployeeKey;
}
}
}