title: Entity Framework is looking up a nonexistent table
body: <p>For the last few days I've been struggling with this problem where Entity framework will look for a nonexistent table. I have no idea why It's doing this either. I attempted to do a code first approach with an existing database, and it's worked absolutely fine as a replacement for all my gateways except 3. All 3 of which deal with this one particular POCO called Student. The POCO class is as follows:</p>
  
  <pre><code>public class Student
  {
      public Guid StudentId { get; set; }
      public String FirstName { get; set; }
      public String LastName { get; set; }
      public String Grade { get; set; }
      public virtual ICollection&lt;CourseOffering&gt; CourseOfferings { get; set; }
  }
  </code></pre>
  
  <p>My context files is: </p>
  
  <pre><code>class GatewayContext : DbContext
  {
      public DbSet&lt;Course&gt; Course { get; set; }
      public DbSet&lt;CourseType&gt; CourseTypes { get; set; }
      public DbSet&lt;CourseOffering&gt; CourseOfferings { get; set; }
      public DbSet&lt;Staff&gt; Staff { get; set; }
      public DbSet&lt;Student&gt; Students { get; set; }
  
      protected override void OnModelCreating(DbModelBuilder modelBuilder)
      {
          modelBuilder.Entity&lt;CourseOffering&gt;()
              .HasMany(x =&gt; x.Students)
              .WithMany(x =&gt; x.CourseOfferings)
          .Map(x =&gt;
          {
              x.ToTable("Students");
              x.MapLeftKey("StudentId");
              x.MapRightKey("CourseOfferings");
          });
      }
  }
  </code></pre>
  
  <p>And my code calling in the gateway using these is:</p>
  
  <pre><code>        try
          {
              GatewayContext context = new GatewayContext();
              var students = from p in context.Students
                             select p;
              var studentList = new List&lt;Services.Proxy.TransferObjects.Student&gt;();
              foreach (var student in students)
              {
                  studentList.Add(student);
              }
              return studentList;
          }
          catch (Exception ex)
          {
              throw;
          }
  </code></pre>
  
  <p>The error this gives me is: "An error occurred while executing the command definition. See the inner exception for details." when using the above code, and when I'm looking the CourseOfferings which contains a Students field for the enrolled students it gives me the error: "An existing connection was forcibly closed by the remote host". When I debug my code I noticed that it appears to be looking for a nonexistent dbo.Students1 table for some reason. Upon further inspection, I do not specify this, or even mention a Students1 in any of my code anywhere. Why would Entity Framework look for a Students1 table instead of my Students table?</p>