title: asp mvc5 adding a table to existing project for dropdown list data
body: <p>Using an asp MVC5 project, has a working SQL table.  Question is how can a 2nd table be added in such that it holds commonly used data such as name, phone, email etc;  Goal is to have dropdowns on the main project on a View page so that they will populate or "auto fill" the related fields for name, email etc. </p>
  
  <pre><code> [Table("newInfoTable")]
  public class InfoTable
  {
  
      [Key]
      public int ID { get; set; }
      [Display(Name = "First Name")]
      [StringLength(255)]
      public string firstName { get; set; }
      [Display(Name = "Last Name")]
      [StringLength(255)]
      public string lastName { get; set; }
      [Display(Name = "Contact Phone Number")]
      public string phoneNumber { get; set; }
      [Display(Name = "Email Address")]
      [StringLength(255)]
      public string emailAddress { get; set; }
      }
  </code></pre>
  
  <p>In the main table, there is a reference to this table:</p>
  
  <pre><code>    public virtual ICollection&lt;InfoTable&gt; InfoTableDat { get; set; }
  </code></pre>
  
  <p>And all of the variable names in this new info table match names in the Main project table.  The new SQL table was created with SQL Management Studio, tested, made a new controller/view and am able to add items/edit or delete to this table from the project.</p>
  
  <p>Within the View, an Edit page, intellisense can see the @Model.InfoTableDat But how to fill the dropdown list?</p>
  
  <p>And is it correct to use "public virtual ICollectioninstanceName" or does that simply link the 2 tables based on the ID? It gets an error:</p>
  
  <blockquote>
    <p>Server Error in '/' Application.</p>
    
    <p>Invalid column name 'MainProj_ID'.<br>
         Description: An unhandled exception occurred during the execution of the      current web request. Please review the stack trace for
    more information about the      error and where it originated in the
    code.</p>
  </blockquote>
  
  <p>The main project class is named MainProj.cs in the Model folder, but there's no MainProj_ID, I never use the underscore for any names.  </p>