title: Entity Framework Navigation Property generation rules
body: <p>I would like to know what rules Entity Framework follows in regards to the naming/generation of navigation properties. I have observed several scenarios which don't seem to make sense so I was wondering if anyone knows exactly how these work.</p>
  
  <p><strong>Scenario 1:</strong> </p>
  
  <pre><code>public class Post
  {
      public int Id { get; set; }
      public User Author { get; set; }
  } 
  </code></pre>
  
  <p>&nbsp;&nbsp;&nbsp;Generates</p>
  
  <p><img src="https://i.stack.imgur.com/TIwdh.png" alt="Scenario 1"></p>
  
  <p>ie. by default navigation properties generate FKs named [PropertyName]_Id </p>
  
  <p><strong>Scenario 2:</strong></p>
  
  <p>It makes sense that if EF generates properties such of the format [PropertyName]_Id when you manually specify a FK Id it will follow the same rules however:</p>
  
  <pre><code>public class Post
  {
      public int Id { get; set; }
      public int? Author_Id { get; set; }
      public User Author { get; set; }
  }
  </code></pre>
  
  <p>&nbsp;&nbsp;&nbsp;Generates</p>
  
  <p><img src="https://i.stack.imgur.com/RxSJ5.png" alt="Scenario 2"></p>
  
  <p>As you can see this doesn't automatically register as a nav property.</p>
  
  <p><strong>Scenario 3:</strong></p>
  
  <p>If it doesn't work for Scenario 2 why does it work for an alternate naming convention?</p>
  
  <pre><code>public class Post
  {
      public int Id { get; set; }
      public int? AuthorId { get; set; }
      public User Author { get; set; }
  }
  </code></pre>
  
  <p>&nbsp;&nbsp;&nbsp;Generates</p>
  
  <p><img src="https://i.stack.imgur.com/hu9w7.png" alt="Scenario 3"></p>
  
  <p>What are the rules around navigation property detection and generation?</p>