Pergunta

I'm generating a model (EDMX) from a SQL Server database, and each time I generate it, it omits one table. I've tried deleting/recreating the table in the database and deleting/recreating the model but it still happens.

The table is a many-to-many linking table:

Companies (CompanyID, Name)
Sectors (SectorID, Name)
Companies_Sectors (CompanyID, SectorID) <-- this table doesn't get mapped

There are many identically structured tables that do get mapped so it's baffling me. I created this one just like the other ones - composite primary key and then the two foreign keys.

When I open the Model.edmx.diagram XML file it looks like this:

<EntityTypeShape EntityType="Model.Companies_Markets" Width="1.5" PointX="21" PointY="37.625" IsExpanded="true" />
<!-- ... -->
<AssociationConnector Association="Model.Companies_Sectors" ManuallyRouted="false" />

('Companies_Markets' is a similar table and that one is mapped fine). It seems like EF just won't recognise 'Companies_Sectors' as a table for some reason. Never had this issue before, what could be the problem?

Foi útil?

Solução

Bridge tables, which only contain the 2 Primary Keys of the linked tables are not supposed to show up.

Further information can be found here:

http://smehrozalam.wordpress.com/2010/06/29/entity-framework-queries-involving-many-to-many-relationship-tables/

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top