title: System.Data.SqlClient.SqlException: Invalid column name 'Gender_id'
body: <p>I am learning Web App development with asp.net mvc &amp; Entity Framework. I have a database with 3 tables students, genders &amp; programs. I encountered this problem. </p>
  
  <p><strong><em>Error is on Line 23.</em></strong></p>
  
  <blockquote>
    <p>Invalid column name 'Genders_Id'.
    Invalid column name 'Programs_Id'.</p>
    
    <p><strong>Exception Details:</strong> System.Data.SqlClient.SqlException: Invalid column name 'Genders_Id'.
    Invalid column name 'Programs_Id'.</p>
  
  <pre><code>Source Error:
  
  
  Line 21:         {
  Line 22:             StudentsContext stdContext = new StudentsContext();
  Line 23:             Students students = stdContext.Students.Single(std =&gt; std.Id == id);
  Line 24:             //ViewBag.Student = students;
  Line 25:             return View(students);
  </code></pre>
  </blockquote>
  
  <p>My code for Students.cs Model:</p>
  
  <pre><code>namespace WebApplication4.Models
  {
    public class Students
    {
       public string Name { get; set; }
       public int Id { get; set; }
       public int Gender { get; set; }
       public int Program { get; set; }
       public string Country { get; set; }
     }
  }
  </code></pre>
  
  <p>My Context.cs file:</p>
  
  <pre><code>public class StudentsContext:DbContext
  {
      public DbSet&lt;Students&gt; Students { get; set; }
      public DbSet&lt;Programs&gt; Programs { get; set; }
      public DbSet&lt;Genders&gt; Genders { get; set; }
  }
  </code></pre>
  
  <p>Programs.cs:</p>
  
  <pre><code>public class Programs
  {
      public int Id { get; set; }
      public string Program { get; set; }
      public List&lt;Students&gt; Students { get; set; }
  }
  </code></pre>
  
  <p>Genders.cs:</p>
  
  <pre><code>public class Genders
  {
      public int Id { get; set; }
      public string Gender { get; set; }
      public List&lt;Students&gt; Students { get; set; }
  }
  </code></pre>
  
  <p>Database tables:</p>
  
  <p><a href="https://i.stack.imgur.com/PjrNd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PjrNd.png" alt="enter image description here"></a></p>