C#C
C#4y ago
İrşat

EF 6 - Creating entity with n-n

    PostDtoWrite_2 newpost = new PostDtoWrite_2();
    newpost.Title = request.Title;
    newpost.PostDescription = request.PostDescription;
    newpost.LanguageId = request.LanguageId;
    newpost.AccountId = request.AccountId;
    newpost.PostTypeId = request.PostTypeId;
    newpost.CoverImage = request.CoverImage;
    newpost.PublishDate = DateTime.Now;
    newpost.UpdateDate = DateTime.Now;
    newpost.DeletedStatusId = 1;
    newpost.PostTypeId = 1;
    newpost.IsPublished = true;

    try{
        db.Posts.Add(mapper.Map<Post>(newpost));
        await db.SaveChangesAsync();
    } catch (Exception) {
        return Results.StatusCode(580);
    }

    return Results.Ok();

I want to add "Tags" to this but there is no table for many to many in new versions of EF.
Was this page helpful?