title: C# Entity Framework Adding to Many-To-Many Table
body: <p>Is this a good practice to insert into a many-to-many table?</p>
  
  <pre><code>user = new User
          {
              Id = userId,
              UserName = username,
              FirstName = firstName,
              LastName = lastName,
              UsersBooks = new List&lt;UsersBooks&gt;()
          };
  
          book = new Book
          {
              Title = "randomTitle2",
              Genre = "randomGenre2",
              UsersBooks = new List&lt;UsersBooks&gt;()
          };
  
          usersBooks = new UsersBooks
          {
              User = user,
              Book = book
          };
  </code></pre>
  
  <p>And at last I add it to the context</p>
  
  <pre><code>actContext.UsersBooks.AddAsync(usersBooks);
  </code></pre>
  
  <p>So I have this UsersBooks collection in each of the classes - user &amp; book. One user can have many books and one book can be acquired by many users(copies of Harry Poter, let's say). So should I every time create a new </p>
  
  <ul>
  <li>usersBook and add it while passing the user and the book each time?
  Because I see that after that the book is added to it's according table, which is correct. Maybe I am asking if there is a better way in terms of most used by experienced developers</li>
  </ul>