title: How to code C# MVC model for many to many join table for sqlite database migration { edited }
body: <p>I am creating a sqlite database to track users assigned to teams. This would mean many-to-many table relationship. I need help making the model for the migration. </p>
  
  <pre><code>users table: 
      public class User
      {
          public int Id { get; set; }
          public string Username { get; set; }
          public ICollection&lt;Photo&gt; Photos { get; set; }
          public virtual ICollection&lt;UserTeam&gt; UserTeams { get; set; }
      }
  
  team table:
      public class Team
      {
          public int Id { get; set; }
          public string Name { get; set; } 
          public User User { get; set; }
          public int UserId { get; set; }
          public virtual ICollection&lt;UserTeam&gt; UserTeams{ get; set; }
      }
  
  UserTeam Table:
      public class UserTeam
      {
          public User User { get; set; }
          public int UserId{ get; set; }
          public Team Team{ get; set; }  
          public int TeamId{ get; set; } //... I have this one for owner of the team
          public string Title { get; set; }
  
      }
  
  DataContext:
      public class DataContext : DbContext
      {
          public DataContext(DbContextOptions&lt;DataContext&gt; options) : base (options) {}
  
          public DbSet&lt;Value&gt; Values { get; set; }
  
          public DbSet&lt;User&gt; Users { get; set; }
  
          public DbSet&lt;Photo&gt; Photos { get; set; }
  
          public DbSet&lt;Team&gt; Teams { get; set; }
  
          protected override void OnModelCreating(ModelBuilder modelBuilder)
          {
              modelBuilder.Entity&lt;UserTeam&gt;()
                  .HasKey(ut =&gt; new { ut.UserId, ut.TeamId });  
              modelBuilder.Entity&lt;UserTeam&gt;()
                  .HasOne(ut =&gt; ut.User)
                  .WithMany(u =&gt; u.UserTeams)
                  .HasForeignKey(ut =&gt; ut.UserId);  
              modelBuilder.Entity&lt;UserTeam&gt;()
                  .HasOne(ut =&gt; ut.Team)
                  .WithMany(t =&gt; t.UserTeams)
                  .HasForeignKey(ut =&gt; ut.TeamId);
          }
      }
  </code></pre>
  
  <p>From what I read declaring I ICollection on team class and user class would force a join table creating. However when I try to migrate, I get this message: Unable to determine the relationship represented by navigation property 'User.Teams' of type 'ICollection'. Either manually configure the relationship, or ignore this property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.</p>
  
  <p>Any suggestions on how to correctly make join tables in sqlite would be helpful</p>