none
Entity Framework many-to-many - adding and retrieving data RRS feed

  • Question

  • I have C# Console project, which has an entity data model in it (edmx).

    In the database and model, I have a few tables with many to many relationships, through an intermediary table. So, the tables look like this:

    Table1:                        Table1ID, Value

    Table2 (intermediate):  Table1ID, Table1ID, MyDate

    Table2:                        Table3ID, value

    My questions are:

    1. How do I add a record to these related entities?
    2. How do I retrieve data from these related entities?


    דוד

    Saturday, August 1, 2015 9:20 AM

Answers

  • Hi Yamnik,

    For insert:

    1. insert entities to Table1 and Table3
    2. insert entity to Table2

    For query:

    1. query entity from Table2 and use .Include.

    Hope above could help you.


    Please mark this as answer if it helps with this issue!

    Monday, August 3, 2015 2:13 AM

All replies