title: Duplicate navigation property cannot be used due to single relationship error
body: <p>I am trying to solve a relatively simple setup but am wondering if there is a better way to set this relation one. </p>
  
  <p>I have a User class that is the starting point for all other relationships. Every other class unless specific conditions are met has a 1-to-many relationship to the User class (e.g. MenuItems is just one of them, there are other classes with the same relationship).</p>
  
  <p>I have a MenuItem class that has has the UserId as the foreign key. I also want to track the user that last updated the item. But if I add the <code>LastUpdatedById</code> and <code>LastUpdatedBy</code> properties, EF core will throw an error due to the navigation property <code>User</code> participating in more than one relationship. </p>
  
  <p>The whole point I was trying to solve this was when fetching the items, to include the <code>Created</code> and <code>LastUpdatedBy</code> properties so that I can easily access the user name + id. <strong><em>Is there a way to solve this or is the only option to make this a many-to-many relationship? If so, what would be the best method to accomplish that?</em></strong></p>
  
  <p>The simplest option would be to make the properties string values and just update them during relevant CRUD operations but I wanted this to be a little more dynamic.</p>
  
  <pre><code>public class User
      {
          [Key]
          public Guid Id { get; set; }
  
          [Required]
          public string Name { get; set; }
  
          [Required]
          public DateTime Created { get; set; }
  
          public ICollection&lt;MenuItem&gt; MenuItems { get; set; }
      }
  
  
  public class MenuItem
      {
          [Key]
          [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
          public int Id { get; set; }
  
          public ItemType Type { get; set; }
  
          [Required]
          public DateTime Created { get; set; }
  
          public int? ParentMenuItemId { get; set; }
  
          public MenuItem ParentMenuItem { get; set; }
  
          public ICollection&lt;MenuItem&gt; ChildMenuItems { get; set; }
  
          [Required]
          public Guid UserId { get; set; }
  
          [Required]
          public User CreatedBy { get; set; }
  
          [Required]
          public Guid LastUpdatedById { get; set; }
  
          [Required]
          public User LastUpdatedBy { get; set; }
      }
  </code></pre>
  
  <hr>
  
  <p>Thanks to David for my solution. I ended up going a slightly different route based on his answer:</p>
  
  <p>I created below 2 properties and deleted the original collection of MenuItem from User. </p>
  
  <pre><code>public ICollection&lt;MenuItem&gt; UpdatedMenuItems { get; set; }
  public ICollection&lt;MenuItem&gt; CreatedMenuItems { get; set; }
  </code></pre>
  
  <p>I also used fluent API to explicitly define the relationship to make it fully defined.</p>
  
  <pre><code>modelBuilder.Entity&lt;MenuItem&gt;()
      .HasOne(x =&gt; x.CreatedBy)
      .WithMany(x =&gt; x.CreatedMenuItems)
      .HasForeignKey(x =&gt; x.UserId)
      .OnDelete(DeleteBehavior.Cascade);
  
   modelBuilder.Entity&lt;MenuItem&gt;()
      .HasOne(x =&gt; x.LastUpdatedBy)
      .WithMany(x =&gt; x.UpdatedMenuItems)
      .HasForeignKey(p =&gt; p.LastUpdatedById)
      .OnDelete(DeleteBehavior.Restrict);
  </code></pre>