Bug #69867 Many to many relationships are broken
Submitted: 30 Jul 2013 0:22 Modified: 8 Aug 2013 17:06
Reporter: Vaughan Hilts Email Updates:
Status: Analyzing Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:6.7.4.0 OS:Windows
Assigned to: Assigned Account CPU Architecture:Any

[30 Jul 2013 0:22] Vaughan Hilts
Description:
I've been using Many-to-Many relationships code-first in the entity framework and adding a migration. I map something like:

 modelBuilder.Entity<GameSessionEntry>().
         HasMany(c => c.Users).
         WithMany(p => p.GameSessionEntries).
         Map(
          m =>
          {
              m.MapLeftKey("SessionId");
              m.MapRightKey("UserId");
              m.ToTable("UserSessions");
          });

And MySQL spits in my face like so:

The Foreign Key on table 'UserSessions' with columns 'UserId' could not be created because the principal key columns could not be determined. Use the AddForeignKey fluent API to fully specify the Foreign Key.

Is the connector not working as intended?

How to repeat:
Simply generate a migration that is used for many to many relationships under the EF.