I am getting data from an NBA API and in order to write the data to my database I need to create the DB object of PlayerGame with composite keys PlayerID and GameID I tried using two [key][column=] tags to define this but when attempting to add the migration I was given the error need to use fluent api. so after some googling I came up with the following code and now upon attempting a migration I am given the error message The entity type 'IdentityUserLogin' requires a primary key to be defined. If you intended to use a keyless entity type call 'HasNoKey()'. I'm guessing it has to do with ApplicationDbCOntext inheriting from IdentityDbContext but I really have no clue what to do at this point. Please help!!
I have a class Player Game
public class PlayerGame
{
[Required]
public int PlayerID { get; set; }
[ForeignKey ("PlayerID")]
public Player Player { get; set; }
[Required]
public int GameID { get; set; }
[ForeignKey ("GameID")]
public Game Game { get; set; }
and DB Context
public class ApplicationDbContext : IdentityDbContext
{
public DbSet<Player> Player {get; set; }
public DbSet<Game> Game { get; set; }
public DbSet<PlayerGame> PlayerGame { get; set; }
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<PlayerGame>()
.HasKey(pg => new { pg.PlayerID, pg.GameID });
}