EF数据库首先拒绝映射表 [英] EF Database First refusing to map a table
问题描述
该表是一个多对多链接表:
公司(CompanyID,Name)
部门(SectorID,Name)
Companies_Sectors(CompanyID,SectorID)< ; - 这个表没有被映射
有许多相同结构化的表, do 被映射,所以这让我很困惑。我创建了一个就像其他的 - 复合主键,然后是两个外键。
当我打开 Model.edmx.diagram
XML文件看起来像这样:
< EntityTypeShape EntityType =Model.Companies_MarketsWidth = 1.5PointX =21PointY =37.625IsExpanded =true/>
<! - ... - >
< AssociationConnector Association =Model.Companies_SectorsManuallyRouted =false/>
('Companies_Markets'是一个类似的表格,映射得很好)。看来EF似乎不会因为某些原因认出Companies_Sectors作为表格。从来没有这个问题,可能是什么问题?
桥表,只包含链接的2个主键表不应该出现。
可以在这里找到更多信息:
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?
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:
这篇关于EF数据库首先拒绝映射表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!