title: Cannot use WithMany in Entity Framework Fluent API
body: <p>I Can't use WithMany for many-to-many connection. I tried everything, and I have not idea what tha problem it could be. Please help if you have some axperience about it.</p>
  
  <p>I have two models "Drink" and "DrinkCategory". every drink could have many categories, so I need many-to-many relationship.</p>
  
  <p>Here is first model "Drink":</p>
  
  <pre><code>public class Drink
  {
      [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
      [Key]
      [Required]
      public int DrinkId { get; set; }
      [Required]
      public int DrinkIngredientId { get; set; }
      public string DrinkName { get; set; }
  
      public virtual DrinkIngredient DrinkIngredients { get; set; }
      public virtual ICollection&lt;DrinkCategory&gt; DrinkCategories { get; set; }
  
  }
  </code></pre>
  
  <p>It is second model "DrinkCategorie":</p>
  
  <pre><code>public class DrinkCategory
  {
      [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
      [Key]
      [Required]
      public int DrinkCategoryId { get; set; }
      public string DrinkCategoryName { get; set; }
      public int? ParentDrinkCategoryId { get; set; }
  
      public virtual ICollection&lt;Drink&gt; Drinks { get; set; }
  }
  </code></pre>
  
  <p>Here is my DBContext: </p>
  
  <pre><code>public class EatAndDrinkDbContext : DbContext
  {
      public EatAndDrinkDbContext(DbContextOptions&lt;EatAndDrinkDbContext&gt; options) : base(options) { }
      public EatAndDrinkDbContext() { }
  
      public DbSet&lt;Drink&gt; Drinks { get; set; }
      public DbSet&lt;DrinkCategory&gt; DrinkCategories { get; set; }
  
  
      protected override void OnModelCreating(ModelBuilder modelBuilder)
      {
          modelBuilder.Entity&lt;Drink&gt;()
           .HasMany(c =&gt; c.DrinkCategories)
           .WithMany(i =&gt; i.Drinks)
           .Map(t =&gt; t.MapLeftKey("DrinkId")
               .MapRightKey("DrinkCategoryId")
               .ToTable("DrinkDrinkCategory"));
  
  
          base.OnModelCreating(modelBuilder);
      }
  </code></pre>
  
  <p>}</p>