locked
Added Table Not Showing RRS feed

  • Question

  • Hi all,

    In our database, we have three tables, items, attributes, and item_attribute. item_attribute simply contains the item id and multiple attribute ids. If I add the three tables to my Entity Framework edmx, the item_attribute table does not show. These tables were created by our DB administrator.

    What I want to do is select the attributes descriptions, but also include the item ID by joining the attributes table with the item_attribute to get the item id. I can do this with a view in SQL, but I wanted to do the join in my class code using LINQ. 

    Any ideas?

    Thanks.

    Friday, May 23, 2014 1:46 PM

Answers

  • It could be that the table was previously on the model and it was deleted. If that is the case, well it was for EF using .NET Framework 3.5, you had to go to the EDMX file with a text-editor and remove any old elements left in the EDMX for  the table if you wanted to add the table back to the model for it to show.

    Otherwise, it would never show on the model because elements for the table were left in the EDMX after the deletion that prevented it from showing on the model. 

    • Marked as answer by Fred Bao Monday, June 2, 2014 5:43 AM
    Friday, May 23, 2014 2:28 PM
  • Hi admdev;

    It sounds like you have a many to many relationship between the two table item and attributes and the third table is what is called a Junction or Bridge table. Entity Framework does not display the Junction table in the model but will handle it for you behind the scenes. Please see the following web page for this type of setup. Entity Framework: Queries involving many to many relationship tables



    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    • Marked as answer by Fred Bao Monday, June 2, 2014 5:43 AM
    Friday, May 23, 2014 8:12 PM

All replies

  • It could be that the table was previously on the model and it was deleted. If that is the case, well it was for EF using .NET Framework 3.5, you had to go to the EDMX file with a text-editor and remove any old elements left in the EDMX for  the table if you wanted to add the table back to the model for it to show.

    Otherwise, it would never show on the model because elements for the table were left in the EDMX after the deletion that prevented it from showing on the model. 

    • Marked as answer by Fred Bao Monday, June 2, 2014 5:43 AM
    Friday, May 23, 2014 2:28 PM
  • Hi admdev;

    It sounds like you have a many to many relationship between the two table item and attributes and the third table is what is called a Junction or Bridge table. Entity Framework does not display the Junction table in the model but will handle it for you behind the scenes. Please see the following web page for this type of setup. Entity Framework: Queries involving many to many relationship tables



    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    • Marked as answer by Fred Bao Monday, June 2, 2014 5:43 AM
    Friday, May 23, 2014 8:12 PM