title: Error message while trying to add foreign key annotation in Entity Framework
body: <p>I'm following a a course on Udemy building a .net and mvc5 project. This project involves using the code first design philosophy for databases.</p>
  <p>Initially the exception I have is</p>
  <blockquote>
  <p>Invalid column name 'Genre_Id1'</p>
  </blockquote>
  <p>I've searched for Genre_Id1 in the entire solution, checked my classes but I'm not quite sure where it is defining or picking up this column name.</p>
  <p>So then I tried to specify manually</p>
  <pre><code>[ForeignKey(&quot;Genre_Id&quot;)] 
  </code></pre>
  <p>but when I tried to add migration after this change , it is unsuccessful and shows message as below</p>
  <blockquote>
  <p>One or more validation errors were detected during model generation:
  Movie_Genre_Target_Movie_Genre_Source: : The types of all properties in the Dependent Role of a referential constraint must be the same as the corresponding property types in the Principal Role. <strong>The type of property 'Genre_Id' on entity 'Movie' does not match the type of property 'Id' on entity 'Genre' in the referential constraint 'Movie_Genre'</strong></p>
  </blockquote>
  <p>As I am a newbie - any help would be much more appreciated. Thanks
  Movie.cs</p>
  <pre><code>public class Movie
      {
          public int Id { get; set; }
          public string Name { get; set; }
         
          public DateTime ReleaseDate { get; set; }
          public DateTime DateAdded { get; set; }
          public int NumberInStock { get; set; }
  
         
          public byte Genre_Id { get; set; }
          [ForeignKey(&quot;Genre_Id&quot;)]
          public Genre Genre { get; set; }
  
      }
  </code></pre>
  <p>Genre.cs</p>
  <pre><code>public class Genre
  {
      public int Id { get; set; }
      [Required]
      public string Name { get; set; }
  }
  </code></pre>