The entity type Identity User Login string requires a primary key to be defined RRS feed

  • Question

  • I tried to add migrations for a composite key in ApplicationDbContext

     public DbSet<Company> Companies { get; set; }
            protected override void OnModelCreating(ModelBuilder modelBuilder)
                    .HasKey(c => new { c.ID, c.IssuerCode });

    I don't know if this is correct, when I try to Add-Migration, it runs, or tries to create a migrations but then stops with a message - 

    The entity type 'IdentityUserLogin<string>' requires a primary key to be defined

    I am in a new project and updated the appsettings.json file in my mvc core project, connection string to a existing database.

    I had Identity selected in the new project and the old database has all the tables for identity. The table in question I assume is dbo.AspNetUserLogins has keys pK and FK so I suspect the problem isn't in the database? 

    Can someone point me to the issue

    Sunday, June 30, 2019 1:26 AM

All replies