title: unable to retrieve metadata for my model class when i want to accesse model data from controller
body: <p>I am trying to make an application where in I have made a Location model,controller and views using scaffolding. I have location name and location ID properties in location. Database is getting created and location table also and data is getting populated. Now i want to make a department class where I have 3 properties namely Dept_ID, Dept_Name and Loc_ID(Foreign key). I have added required codes in respective files as following.</p>
  
  <p>in Department.cs(Model)</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.ComponentModel.DataAnnotations;
  
  namespace DMS.Models
  {
      public class Department
      {
          public int D_ID { get; set; }
          public string D_Name { get; set; }
          [ForeignKey("L_ID")]
          public int L_ID { get; set; }
  
      }
  } 
  </code></pre>
  
  <p>in DB_CONTEXT class</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Data.Entity;
  
  namespace DMS.Models
  {
      public class DB_CONTEXT : DbContext
      {
          public DbSet&lt;Location&gt; Movies { get; set; }
          public DbSet&lt;Department&gt; Department { get; set; } 
      }
  }
  </code></pre>
  
  <p>and in locatoin.cs(Model)</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  
  namespace DMS.Models
  {
      public class Location
      {
          public int ID { get; set; }
          public string L_Name { get; set; }
      }
  }
  </code></pre>
  
  <p>when i am trying to add a controller for Department I am getting an error as </p>
  
  <pre><code>unable to retrieve metadata for 'DMS.Models.Department' The navigation property 'L_ID' is not declared property on type Department.Verify that it has not been explicitly excluded from the model and that it is a  valid navigation property.
  </code></pre>