title: Using Lists with Many-to-Many relationship in Entity Framework Core
body: <p>So i'm developing a basic project which uses Entity Framework Core to create a database that fetches information from TMDB based on whatever movie I enter to try and understand the whole thing better.</p>
  
  <p>I've been stuck for a while trying to implement a Many-to-Many relationship between my Movie and Studio models. </p>
  
  <p>Movies can have many studios attributed to them, but there are also many movies that will be connected to the studios, so it's the clear relationship to use.
      Below are snippets from those models:</p>
  
  <pre><code>public class Movies
  {
      [Key]
      public int MovieID { get; set; }
      public ICollection&lt;MovieStudios&gt; MovieStudios { get; set; } = new List&lt;MovieStudios&gt;();
  }
  public class Studios
  {
      [Key]
      public int StudioID { get; set; }
      public ICollection&lt;MovieStudios&gt; MovieStudios { get; set; } = new List&lt;MovieStudios&gt;();
  }
  </code></pre>
  
  <p>And here is the join table that i've got</p>
  
  <pre><code>public class MovieStudios
  {
      public int MovieID { get; set; }
      public Movies Movie { get; set; }
      public int StudioID { get; set; }
      public Studios Studio { get; set; }
  }
  </code></pre>
  
  <p>And here is my DbContext class:
          public class MyDbContext : DbContext
      {
          public DbSet TblMovies { get; set; }
          public DbSet TblStudios { get; set; }</p>
  
  <pre><code>    protected override void OnConfiguring(DbContextOptionsBuilder option)
      {
          option.UseSqlServer(@"Server=(localdb)\MSSQLLocalDB; Database=ServerDatabase ; Trusted_Connection=True;");
      }
  
      protected override void OnModelCreating(ModelBuilder modelBuilder)
      {
          modelBuilder.Entity&lt;MovieStudios&gt;()
              .HasKey(bc =&gt; new { bc.MovieID, bc.StudioID });
      }
  }
  </code></pre>
  
  <p>What I want to do, in one of my services, is return List so that I can link these studios to the movie in question when a movie is added to the database, but i'm just completely lost as for what to do. Sorry if this is a noob question, of if this is too long, just feel completely lost!</p>
  
  <p>EDIT:
  To be more specific, I pass through the TMDB id of a film to a service i've created that returns a list of the ids of the films production studios e.g.('46226', '6735'), which is then saved in my database and also returns the index number of my Studio database so that it can be added to my film. ('1', '4', '6'). I've stored this as a List and am stuck as to how I can add these studio ids to the film i'm trying to add to the database. All examples i've seen don't really address what i'm trying to do. I'm trying to add Many studios to the one film.</p>