Many-to-many relationship between entities of same type in MVC3
I have an ASP.NET MVC3 application, where I use Entity Framework 4.3 Code-First and Migrations.

I've been trying to create a many-to-many relationship between entities of the same type, but when I scaffold the migration with Migrations, it generates a one-to-one relationship.

The idea is that one user should be able to follow multiple other users (think Twitter).

My `User` model look something like this:

    public class User
    {
        public int UserId { get; set; }
        public string Name { get; set; }
        public DateTime Registered { get; set; }
        ...
        public virtual ICollection<User> Follows { get; set; }
    }

When I scaffold the the added Follows-property, I get a migration like this:

    public partial class FollowUser : DbMigration
    {
        public override void Up()
        {
            AddColumn("User", "User_UserId", c => c.Int());
            AddForeignKey("User", "User_UserId", "User", "UserId");
            CreateIndex("User", "User_UserId");
        }

        ...
    }

So Entity Framework interprets my model as a one-to-one relationship between two users.

**How can I create a many-to-many relationship between entities of the same type?**
Many-to-many relationship between entities of same type in MVC3
===

I have an ASP.NET MVC3 application, where I use Entity Framework 4.3 Code-First and Migrations.

I've been trying to create a many-to-many relationship between entities of the same type, but when I scaffold the migration with Migrations, it generates a one-to-one relationship.

The idea is that one user should be able to follow multiple other users (think Twitter).

My `User` model look something like this:

    public class User
    {
        public int UserId { get; set; }
        public string Name { get; set; }
        public DateTime Registered { get; set; }
        ...
        public virtual ICollection<User> Follows { get; set; }
    }

When I scaffold the the added Follows-property, I get a migration like this:

    public partial class FollowUser : DbMigration
    {
        public override void Up()
        {
            AddColumn("User", "User_UserId", c => c.Int());
            AddForeignKey("User", "User_UserId", "User", "UserId");
            CreateIndex("User", "User_UserId");
        }

        ...
    }

So Entity Framework interprets my model as a one-to-one relationship between two users.

**How can I create a many-to-many relationship between entities of the same type?**