加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

entity-framework – Entityframework Mapping问题

发布时间:2020-12-16 06:50:21 所属栏目:asp.Net 来源:网络整理
导读:我在mvc上使用实体框架,但我遇到了这个方法的问题.我正在做的只是下面的反射方法,不明白为什么我得到一个字段映射错误. 我也在这里提到的字段中得到以下错误. 错误: – Error 13 Error 3021: Problem in mapping fragments starting at line 205:Each of th
我在mvc上使用实体框架,但我遇到了这个方法的问题.我正在做的只是下面的反射方法,不明白为什么我得到一个字段映射错误.

我也在这里提到的字段中得到以下错误.

错误: –

Error   13  Error 3021: Problem in mapping fragments starting at line 205:Each of the following   
columns in table FormBuilder_Form_Fields is mapped to multiple conceptual side properties:
FormBuilder_Form_Fields.ID is mapped to <FormFieldsForm.Form.ID,FormFieldsForm.FormFields.ID>
 C:NewDevelopmentCaseddimensionsCMSCaseddimensionsCMSCaseddimensionsCms.edmx    206 11  CaseddimensionsCMS

Error   14  Error 3021: Problem in mapping fragments starting at line 228:Each of the following columns in table FormBuilder_field_values is mapped to multiple conceptual side properties:
FormBuilder_field_values.ID is mapped to <FormFieldValues.FieldValues.ID,FormFieldValues.Form.ID>

我不确定这对实体框架来说意味着什么.

我在布局设计器中包含了edmx文件的屏幕截图:

这是我的edmx文件的pastbin

http://pastebin.com/GeL6mZd4

至于代码不想在这里发布它.

解决方法

遇到同样的问题,我找到了解决方案 here.
简而言之,你应该:

Fixing this duplicate mapping issue requires a referential constraint,
which the designer will only support in the next release,so save the
edmx file,close it,then right-click it in Solution Explorer,select
“Open With…” and double click on “XML Editor”.

In the CSDL section,you will see the ProductProductImages
association:

更新您的关联,例如:

<Association Name="FormsFormsFields">
  <End Type="TableSplittingModel.Forms" Role="Form" Multiplicity="1" />
  <End Type="TableSplittingModel.FormFields" Role="FormFields" Multiplicity="1" />
</Association>

通过添加ReferentialConstraint

<Association Name="FormsFormFields">
  <End Type="TableSplittingModel.Forms" Role="Forms" Multiplicity="1" />
  <End Type="TableSplittingModel.FormFields" Role="FormFields" Multiplicity="1" />
  <ReferentialConstraint>
    <Principal Role="Forms"><PropertyRef Name="id"/></Principal>
    <Dependent Role="FormFields"><PropertyRef Name="id"/></Dependent>
  </ReferentialConstraint>
</Association>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读