Many to many with extra foreign key?
<p>I want to generate a junction table between user and post and I want to have the userId in the post table.</p>

<p>I have this code</p>

<pre><code>public class Post
{
    public Post()
    {
        this.ApplicationUser = new HashSet&lt;ApplicationUser&gt;();
    }

    public int PostId { get; set; }
    public string Message { get; set; }
    public DateTime MessageDate { get; set; }

    public virtual ApplicationUser User { get; set; } //this is the problem

    public virtual ICollection&lt;ApplicationUser&gt; ApplicationUser { get; set; }
}

public class ApplicationUser : IdentityUser
{
   public async Task&lt;ClaimsIdentity&gt; GenerateUserIdentityAsync(UserManager&lt;ApplicationUser&gt; manager)
    {
        // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
        var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
        // Add custom user claims here
        return userIdentity;
    }

   public ApplicationUser()
   {
       this.Posts = new HashSet&lt;Post&gt;();
   }

   public virtual ICollection&lt;Post&gt; Posts { get; set; }
}
</code></pre>

<p>I get the extra junction table and many-to-many relation between user and post. But this is wrong.</p>

<pre><code>   public virtual ApplicationUser User { get; set; }
</code></pre>

<p>This generates two UserId in the post table (applicationUser_id and User_id) and Post_PostId in the User table. I just want one extra field in the Post table, FK UserId. </p>

<p>I want three tables like this</p>

<p><strong>Post</strong></p>

<p>PostId
Message
Date
<em>UserId FK</em></p>

<p><strong>User</strong></p>

<p>UserId
And the rest of the fields in asp.net identity user</p>

<p><strong>UserPosts</strong></p>

<p>UserId
PostId</p>