Part 22 Many to many relationship in entity framework
Why Stack Overflow recommends it
Stack Overflow users link it when answering Entity Framework questions about bridge tables and many-to-many relationships that show up as navigation properties instead of separate entities.
Recommended by 2 people across 2 different months, 2015 to 2015.
What it is
Part 22 of kudvenkat's Entity Framework tutorial series, showing how many-to-many relationships work with the database-first approach. Using Students, Courses and a StudentCourses bridge table, it shows how EF generates only two entities joined by a many-to-many association.
What people said
Recommends SmartDev · 2015-02 · Stack Overflow · on “Optimizing the LINQ expressions”
What you are trying to achieve is a many-to-many relationship using a bridge table . I suggest checking this tutorial at: [this video] . Basically what you need to do is to remove the IndexNum column. Then you should re-generate your model and you will be able to check for: var groceries = user.Groceries; var users = gorcery.Users;
Recommends fradique · 2015-06 · Stack Overflow · on “Entity Framework - Searching by ID”
Supposing that you want a product to have a single description you either have to add the ProductId field to ProductDescription table or the ProductDescriptionID field to the Product table. This is called Entity splitting, you can find a video of this approach here. [LINK] Supposing that you want a product to have multiple descriptions and description multiple products (many to many) you need a "Bridge Table" with just two fields (product and description ids) conforming the primary key of this bridge table, this way you will have in your model a (many to many) relation, again there is a detailed video here. [this video] .
Cites Monah · 2015-07 · Stack Overflow · on “Entity Framework 6 - Missing table with only primary keys referencing different tables”
Weak entities or join tables will not be generated by EF, you need to configure the relationships manually thru fluent API or using data annotations As stated on Microsoft's website: under Relationship's convention: Note: If you have multiple relationships between the same types (for example, suppose you define the Person and Book classes, where the Person class contains the ReviewedBooks and AuthoredBooks navigation properties and the Book class contains the Author and Reviewer navigation properties) you need to manually configure the relationships by using Data Annotations or the fluent API. For more information, see Data Annotations - Relationships and Fluent API - Relationships. Refer to