I am playing around with Entity Framework for a POC project.
In my database I have
Category<-------CategoryProduct ------->Product
(Where the join table is an entity in the model.)
How can I do select / insert / update or delete on this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming the
CategoryProducttable is simply made up of two FKs one toProductand one toCategory… the EF will by default not produce aCategoryProductentity, instead to manipulate that table you will need to create / delete relationships usingProduct.CategoriesorCategory.Productscollections.I.e. to add a row:
To remove a row:
To query the table i.e. to get the rows in that table:
And update doesn’t make sense, because the PK (which can’t change) is all the columns, i.e. none of the row’s columns can be update, so the row itself can’t be updated (excluding deletes of course).
Hope this helps
Alex James