у меня есть код
// Controllers/BooksController.cs
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using RelationsDemo.Data;
using RelationsDemo.Models;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using RelationsDemo.Models.ViewModels;

namespace RelationsDemo.Controllers
{
    public class BooksController : Controller
    {
        private readonly ApplicationDbContext _context;

        public BooksController(ApplicationDbContext context)
        {
            _context = context;
        }

        // GET: Books
        public async Task<IActionResult> Index()
        {
            var books = _context.Books
                                .Include(b => b.Author)
                                .Include(b => b.BookTags)
                                    .ThenInclude(bt => bt.Tag);
            return View(await books.ToListAsync());
        }

        // GET: Books/Details/5
        public async Task<IActionResult> Details(int? id)
        {
            if (id == null)
            {
                return NotFound();
            }

            var book = await _context.Books
                                     .Include(b => b.Author)
                                     .Include(b => b.BookTags)
                                         .ThenInclude(bt => bt.Tag)
                                     .FirstOrDefaultAsync(m => m.Id == id);
            if (book == null)
            {
                return NotFound();
            }

            return View(book);
        }

        // GET: Books/Create
        public IActionResult Create()
        {
            ViewData["AuthorId"] = new SelectList(_context.Authors, "Id", "Name");
            ViewData["Tags"] = new MultiSelectList(_context.Tags, "Id", "Name");
            return View();
        }

        // POST: Books/Create
        [HttpPost]
        [ValidateAntiForgeryToken]
        public async Task<IActionResult> Create(BookCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                var book = new Book
                {
                    Title = model.Title,
                    AuthorId = model.AuthorId
                };
                _context.Books.Add(book);
                await _context.SaveChangesAsync();

                // Добавление BookTags
                if (model.SelectedTagIds != null)
                {
                    foreach (var tagId in model.SelectedTagIds)
                    {
                        var bookTag = new BookTag
                        {
                            BookId = book.Id,
                            TagId = tagId
                        };
                        _context.BookTags.Add(bookTag);
                    }
                    await _context.SaveChangesAsync();
                }

                return RedirectToAction(nameof(Index));
            }
            ViewData["AuthorId"] = new SelectList(_context.Authors, "Id", "Name", model.AuthorId);
            ViewData["Tags"] = new MultiSelectList(_context.Tags, "Id", "Name", model.SelectedTagIds);
            return View(model);
        }

        // Дополнительные методы (Edit, Delete) можно добавить по аналогии

        private bool BookExists(int id)
        {
            return _context.Books.Any(e => e.Id == id);
        }
    }

}
нужно вместо viewdata использовать viewmodel