Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework generation missing an entity

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!

like image 314
Hidan Avatar asked Jan 18 '12 18:01

Hidan


1 Answers

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.

like image 181
Slauma Avatar answered Sep 22 '22 21:09

Slauma