Hello,I'm trying to learn asp.net core with razor and I'm trying to make a videogame database to keep a track of finished games, games I haven't played yet, etc.
But I have a problem. I have a table game and a table Developer. Since a game can have many developers and a developer can have many games y made a third table DeveloperXGame. They are something like this:
public class Game { public int Id { get; set; } public string Name { get; set; } } public class Developer { public int Id { get; set; } public string Name { get; set; } } public class DeveloperXGame { public int DeveloperId { get; set; } public int JuegoId { get; set; } public Developer Developer { get; set; } public Game Game { get; set; } } public class ApplicationDbContext : DbContext { public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { } public DbSet<Game> Game { get; set; } public DbSet<Developer> Developer { get; set; } public DbSet<DeveloperXGame> DeveloperXGame { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity<DeveloperXGame>() .HasKey(m => new { m.DeveloperId, m.GameId }); } }
I already did the pages for the developers so I first create them manually. Now I'm trying to create the games and I want to show a select where I can select one or more developers of that list (next step will be to try to add them with ajax through the games page if they don't exists). But I'm lost beyond this point.
I don't know how to load the list of developers in that list and later on post how to save those selected items in the table DeveloperXGame.
Thanks