public ActionResult Create(Department department)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.Departments.AddObject(department);
                    db.SaveChanges();
                    return RedirectToAction("Index");
                }

            }
            catch (Exception)
            {
                throw;
            }
            return View(department);
        }
 public ActionResult Edit(Department department)
 {
     if (ModelState.IsValid)
     {
         db.Departments.Attach(department);
         db.ObjectStateManager.ChangeObjectState(department, EntityState.Modified);
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(department);
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Departments EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToDepartments(Department department)
 {
     base.AddObject("Departments", department);
 }
 /// <summary>
 /// Create a new Department object.
 /// </summary>
 /// <param name="deptNo">Initial value of the DeptNo property.</param>
 /// <param name="dname">Initial value of the Dname property.</param>
 /// <param name="location">Initial value of the Location property.</param>
 public static Department CreateDepartment(global::System.Int32 deptNo, global::System.String dname, global::System.String location)
 {
     Department department = new Department();
     department.DeptNo = deptNo;
     department.Dname = dname;
     department.Location = location;
     return department;
 }