add the following to the model.
public int Department { get; set; }
public IEnumerable<angtestdepartment> Departments { get; set; }</angtestdepartment>
add the following to the controller
public ActionResult CreateEmployee()
{
using (var db = new DepartmentDbContext())
{
var model = new CreateEmployee();
model.Departments = db.AngTestDepartments.ToList();
return View(model);
}
}
add the following to the view
@Html.DropDownListFor(m => m.Department,
Model.Departments.Select(d => new SelectListItem()
{
Value = d.id.ToString(),
Text = d.Department
}))
answer link