简体   繁体   中英

Entity Framework EDMX Relationship Mapping Table

I have a users table and a roles table.
To link the two together I have created a UsersInRoles table which has a foreign key to the Users' UserId and another foreign key to the Roles' RoleName.

However, when I generate an EDMX from the database instead of a separate table for UsersInRoles, an association is created instead. Should I be using this association or should I try to figure out how to get the UsersInRoles table to be generated?

This is the normal behavior of Entity Framework. The tables used to create n - n relationships are not created in the model as entities(The tables used as a middle table to create a relationship between two tables).

Instead you will observe an n to n relationship between Users and Roles entities.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM