I'm currently using Entity Framework 7.0.0-beta3 and am trying to create a many-to-many relationship between two tables. For that I'm using the syntax from The answer of this question, minus the ICollections:
public class Permissions
{
public Guid PermissionId { get; set; }
public string Name { get; set; }
public string Description { get; set; }
}
public class relUserPermissions
{
public string UserId { get; set; }
public ApplicationUser User { get; set; }
public Guid PermissionId { get; set; }
public Permissions Permission { get; set; }
}
ApplicationUser
is referring to the AspNetUsers
Table. Using the kpm migration tool, this will create the relUserPermissions
Table with foreign keys to both AspNetUsers
and Permissions
.
As I'm trying to access this via LINQ, I need to add the relation to the Database Context, using public DbSet<relUserPermissions> relUserPermission { get; set; }
. But once I add that line, the foreign key to Permissions
is no longer generated, the foreign key to AspNetUsers
still is.