I'm trying to generate my entities from my SQL database using the ADO.NET Entity Data Model item and from there using the ADO.NET DbContext Generator. When I generate my edmx from the database one of my entities seems to be missing in the designer but when I look at the code behind of the edmx I see it in code and when I generate the dbContext the entity isn't generated at all...
Any advice would be greatly appreciated!
If the table you are missing an entity for is a join table for a many-to-many relationship you don't get an entity class when you create a model from the database. EF recognizes this when the table has two columns which form a composite primary key and each column is a foreign key to two other tables.
EF manages the join table internally and doesn't expose it as an entity. You only have the "left" and the "right" entity with navigation collections pointing to each other. If you add or remove a relationship by adding or removing elements to those collections EF will create the correct INSERT and DELETE statements for the join table when you call SaveChanges
. But this happens internally and is completely hidden to you.
In other words: Everything is OK.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With