Search code examples
sqlasp.netentity-frameworkssmsef-power-tools

EF Core Power tools does not load models of many to many junction table into asp.net wep api project


I am loading 6 different models from SQL-Server-Management-Studio via EF Core Powertools into my web api project.

Models look like this: Table Diagram

I got follwoing Models in my project.

Models

I want to add a picture with the list of tags and categories like this.

      var picture = new PressPicPicture
            {
                Image = bytes,
                CreatedAt = request.CreatedAt,
                CreatedBy = request.CreatedBy
            };

            await _pictureRepository.AddPicture(picture, cancellationToken);
           
            foreach (var catId in request.CategoryIds)
            {
                var picutureCategory = new PressPicPictureCategories
                {
                    IdPicture = picture.Id,
                    IdCat = catId
                };
                await picutureCategory.AddPictureTag(picutureCategory, cancellationToken);
            }

My problem is that i cant access the PressPicPictureCategories Model because i dont get it into my project with EF-Core-Powertools 6. So my question is: Is there a way to solve this?


Solution

  • Solved it! Options/Advanced --> use many to many relations