必须将外键映射到概念上参与外键关联的某些AssociationSet或EntitySet [英] Foreign key must be mapped to some AssociationSet or EntitySets participating in a foreign key association on the conceptual side
问题描述
我试图在Entity Framework中使用一对一(主,详细)关系,但是,出现此错误:
映射问题从第254行,第443行开始的片段:从表options_Advanced(ProductID)到表产品(catalogid)的外键约束'options_Advanced_FK00'::映射不足:外键必须映射到参与该概念上外键关联的某些AssociationSet或EntitySet侧面
这是设计者中的关联:
它表示乘积-> 0..1 options_Advanced
我先使用模型而不是代码。我的高级选项表中的每条记录都有一个产品
产品
- ID
- 目录ID
- 名称
Options_Advanced
- ID
- ProductID
- 名称
在我正在研究的系统中寻找相同问题的解决方案时,我遇到了这个问题。 / p>
我在VS2010中遇到了这个问题,当您像以前一样从数据库生成模型并且您不同时包含对象时,似乎会发生这种情况。即,包括一个表而不包含另一个表。
我现在通过删除模型,然后重新创建整个模型并包括模型中的每个表来解决它
现在我不确定在添加新表时会发生什么,因为我在使用旧应用程序时还不需要这样做我们希望转换的
I am trying to use a one to one (master, detail) relationship in Entity Framework, however, I get this error:
Problem in mapping fragments starting at lines 254, 443:Foreign key constraint 'options_Advanced_FK00' from table options_Advanced (ProductID) to table products (catalogid):: Insufficient mapping: Foreign key must be mapped to some AssociationSet or EntitySets participating in a foreign key association on the conceptual side
Here is the association in the designer:
It says product --> 0..1 options_Advanced
I used model-first and not code first. My Options Advanced table has one product associated with each record
Products
- ID
- CatalogID
- Name
Options_Advanced
- ID
- ProductID
- Name
I came accross this when searching for a solution to the same issue in a system I was working on.
I encountered this in VS2010 and it seems to happen when you are generating the model from the database as I was and you don;t include the objects at the same time. i.e including one table and not the other.
I got around it at this point by deleting the model and then recreating the entire model and including every table in the model that I thought I might need.
Now what happens when you add a new table I am not certain as I have not had to do this yet as I am working with an old application that we wish to convert
这篇关于必须将外键映射到概念上参与外键关联的某些AssociationSet或EntitySet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!