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.
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.