I'm doing a "manga website" with ASP.NET Core and Entity Framework and Razor pages. What I'm trying to do is having my MangaModul become MangaAuthorArtistGroupScanlationChapterPost Module to speak with multiple many to many modules in the database,for when i want to retrieve information.
An example would be of :
a one entity many to many would be Manga Module / Author Module =
MangaAuthorModuleMy Goal is to have a Joint table of all the ICollections
MangaAuthorArtistGroupScanlationChapterPost
I am fully aware that I have not made a
protected override void OnModelCreating(ModelBuilder modelBuilder)
I tried using EF6s relationship builder, To fix aMangaAuthorArtist~Modul in the database, however it did not work.
My first guess is that the complexity of relationship isn't doable with automatic EF with these many relationship binding, and I need to write them myself.
2nd guess is that somewhere I'm doing a big mistake in the module where I construct them.
I have read
- Entity Framework Core Multiple Many-to-many with linking table (join entity)
- Entity Framework - Modelleing Many-to-Many-to-Many Relationship
and several others, but my findings are often same as it's a single many to many relationship (which I already know how to solve)
public class AuthorModel
{
[Key]
public int AuthorId { get; set; }
~Info~
ICollection<MangaModel> Models { get; set; }
}
public class ArtistModel
{
[Key]
public int ArtistId { get; set; }
~Info ~
ICollection<MangaModel> Models { get; set; }
}
public class PostModel
{
[Key]
public int PostId { get; set; }
public int MangaId { get; set; }
public MangaModel mangaModel { get; set; }
}
public class StudioModel
{
[Key]
public int StudioId { get; set; }
Info
}
public class PostModel
{
[Key]
public int PostId { get; set; }
Info
public int MangaId { get; set; }
public MangaModel mangaModel { get; set; }
}
public enum GenresModel
{
None,
Action,
Adult,
Adventure,
}
public enum ThemeModel
{
None,
Action,
Adult,
Adventure,
}
public class ChapterModel
{
[Key]
public int chapterID { get; set; }
public int MangaId { get; set; }
public MangaModel mangaModel { get; set; }
}
public class MangaModel
{
[Key]
public int MangaID { get; set; }
[Required(ErrorMessage = "Name is required"),
MinLength(2, ErrorMessage = "Name must contain at least 2 characters")]
public string MangaName { get; set; }
~Info~
public GenresModel? Genres { get; set; }
public ThemeModel? Theme { get; set; }
ICollection<StudioModel> StudioModels { get; set; }
ICollection<ArtistModel> ArtistModels { get; set; }
ICollection<AuthorModel> AuthorModels { get; set; }
ICollection<ChapterModel> ChaptersModels { get; set; }
ICollection<PostModel> Posts { get; set; }
ICollection<GroupScanlatingModel> GroupScanlatingModels { get; set; }
}
public class MangaNNovelAuthDBContext : IdentityDbContext
{
public MangaNNovelAuthDBContext(DbContextOptions<MangaNNovelAuthDBContext> options) : base(options)
{
}
public DbSet<ArtistModel> artistModels { get; set; }
public DbSet<AuthorModel> authorModels { get; set; }
public DbSet<ChapterModel> chapterModels { get; set; }
public DbSet<GroupScanlatingModel> groupScanlatingModels { get; set; }
public DbSet<StudioModel> studioModels { get; set; }
public DbSet<PostModel> Posts { get; set; }
public DbSet<MangaModel> mangaModels { get; set; }
}
A photo of the migrated database:
"Edited Wrong picture from another DB, but same problem. Correct picture is now in place." []
I have tried creating my own relationship paths with OnModelCreating(ModelBuilder modelBuilder), but it does not give any result.
I have succeeded with a previous work, but the modules were only 2. so It was a single Many to many relationship and not Multiple many to many relationship where several modules speak with the same module
Book and Author, where EF successfully created BookAuthor.