title: An exception of type 'System.InvalidOperationException' occurred in EntityFramework.dll but was not handled in user code
body: <p>I am trying to make dropdownlist for department name. I am using MVC5. I saw too much solution on stack overflow but I never found valuable solution related to MVC5.</p>
  
  <pre><code>Database Name : AppraisalDBContext
  Table Name :  Department
  Column Name : deptID (Primarykey)
                deptName (department name)
                Description 
  </code></pre>
  
  <p>I am getting this error :</p>
  
  <pre><code>An exception of type 'System.InvalidOperationException' occurred in  EntityFramework.dll but was not handled in user code
  
  Additional information: The model backing the 'AppraisalDBContext' context has changed since the database was created.Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?
  </code></pre>
  
  <p><strong>Code:</strong></p>
  
  <p>Controller class Name (DepartmentController.cs):</p>
  
  <pre><code>public ActionResult Index(string depName)
  {
      var DeptLst = new List&lt;string&gt;();          
      var GenreQry = from d in db.Department
                     orderby d.deptName
                     select d.deptName;
  
      DeptLst.AddRange(GenreQry);                // Here I am confusing
      ViewBag.depName = new SelectList(DeptLst); // Here I am confusing
      var depts = from m in db.Department        // Here I am confusing
                  select m;
  
  
      return View(depts);
  }
  </code></pre>
  
  <p>Model class Name (Departments.cs) :</p>
  
  <pre><code>namespace appraisalProject.Models
  {
      [Table("Department")]
      public class Departments
      {
          [Key]
          public int deptId { get; set; }
          public string deptName { get; set; }
          public string Description { get; set; }
       }
  }
  </code></pre>
  
  <p>Model class Name (AppraisalDBContext.cs) :</p>
  
  <pre><code>namespace appraisalProject.Models
  {
      public class AppraisalDBContext:DbContext
      {
          public DbSet&lt;Departments&gt; Department { get; set; }
      }
  }
  </code></pre>
  
  <p>Index.cshtml :</p>
  
  <pre><code>@using (Html.BeginForm())
  {
  &lt;p&gt;
      Genre: @Html.DropDownList("depts", "All")
      &lt;input type="submit" value="Filter" /&gt;
  &lt;/p&gt;
  }
  </code></pre>