IdentityUserLogin<string>' requires a primary key to be defined error while adding migration : <p>I am using 2 different Dbcontexts. i want to use 2 different databases users and mycontext. While doing that i am getting a error The entity type 'Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserLogin' requires a primary key to be defined. I think there is something wrong with IdentityUser please suggest me where can i change my code so that i can add migration.</p>

<p>My Dbcontext class:</p>

<pre><code> class MyContext : DbContext
{
    public DbSet&lt;Post&gt; Posts { get; set; }
    public DbSet&lt;Tag&gt; Tags { get; set; }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        base.OnModelCreating(modelBuilder);

        modelBuilder.Entity&lt;PostTag&gt;()
            .HasKey(t =&gt; new { t.PostId, t.TagId });

        modelBuilder.Entity&lt;PostTag&gt;()
            .HasOne(pt =&gt; pt.Post)
            .WithMany(p =&gt; p.PostTags)
            .HasForeignKey(pt =&gt; pt.PostId);

        modelBuilder.Entity&lt;PostTag&gt;()
            .HasOne(pt =&gt; pt.Tag)
            .WithMany(t =&gt; t.PostTags)
            .HasForeignKey(pt =&gt; pt.TagId);
    }
}

public class Post
{
    public int PostId { get; set; }
    public string Title { get; set; }
    public AppUser User {get; set;}
    public string Content { get; set; }

    public List&lt;PostTag&gt; PostTags { get; set; }
}

public class Tag
{
    public string TagId { get; set; }

    public List&lt;PostTag&gt; PostTags { get; set; }
}

public class PostTag
{
    public int PostId { get; set; }
    public Post Post { get; set; }

    public string TagId { get; set; }
    public Tag Tag { get; set; }
}
</code></pre>

<p>and AppUser class:</p>

<pre><code>public class AppUser : IdentityUser
{
  //some other propeties
}
</code></pre>

<p>when I try to Add migration the following error occurs.</p>

<pre><code>The entity type 'Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserLogin&lt;string&gt;' requires a primary key to be defined.
</code></pre>

<p>give me solution to resolve the issue..</p>
