title: Entity Framework - Invalid column name 'CourseLesson_Id'
body: <p>After trying to execute the following query:</p>
  
  <pre><code>List&lt;CourseLesson&gt; courseLessons = (from cl in context.CourseLessons
                                                  .Include(x =&gt; x.CourseLessonTestQuestions)
                                                  select cl).ToList();
  </code></pre>
  
  <p>I get the the error Invalid column name 'CourseLesson_Id'.</p>
  
  <p>My models and DataContext looks like this(this is from a test project I've created to repreduce the problem)</p>
  
  <pre><code>public class CourseLesson
  {
      public int Id { get; set; }
  
      public string Title { get; set; }
  
      public string Content { get; set; }
  
      public ICollection&lt;CourseLessonTestQuestion&gt; CourseLessonTestQuestions { get; set; }
  
  }
  
  public class CourseLessonTestQuestion
  {
  
      public int Id { get; set; }
  
      public int CourseLessonId { get; set; }
  
      [ForeignKey(nameof(CourseLessonId))]
      public CourseLesson CourseLesson { get; set; }
  
      public int? ReturnCourseLessonId { get; set; }
  
      [ForeignKey(nameof(ReturnCourseLessonId))]
      public CourseLesson ReturnCourseLesson { get; set; }
  }
  </code></pre>
  
  <p>I have 2 foreign keys that point to the same table and I'm assuming EF is trying to create or map something that doesn't really exist.</p>
  
  <p>After reading for a while I've found a way to fix my problem in (<a href="https://stackoverflow.com/questions/41719988/entity-framework-invalid-column-name-courselesson-id">this answer</a>) with the following code:</p>
  
  <pre><code>            modelBuilder.Entity&lt;CourseLessonTestQuestion&gt;()
                  .HasOptional(cltq =&gt; cltq.ReturnCourseLesson)
                  .WithMany(x =&gt; x.CourseLessonTestQuestions);
  </code></pre>
  
  <p>What really bugs me about this situation is why everything works when I use the Fluent API, but it doesn't work with the ForeignKey attribute? This looks like something that could lead to future problems and I want to know what is really happening.</p>
  
  <p>And the real question is there a solution for fixing this problem without the Fluent API? Like using attributes or some other convention?</p>
  
  <p>I'm using Entity Framework 6.1.3</p>