Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entityframework Mapping Issue

I am using entity framework on mvc but I am having a problem with this method. All I am doing is a reflection method below and don't understand why I am getting a field mapping error.

I also get the following error on the fields mentioned here.

Error :-

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:\NewDevelopment\CaseddimensionsCMS\CaseddimensionsCMS\CaseddimensionsCms.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>

I am not to sure what this means as quite new to entity framework.

I have included a screen shot of the edmx file in the layout designer:

pic

This is a pastbin of my edmx file

http://pastebin.com/GeL6mZd4

As to long a code didnt want to be posting it here.

like image 781
c-sharp-and-swiftui-devni Avatar asked Aug 07 '14 08:08

c-sharp-and-swiftui-devni


1 Answers

Having the same issue I found the solution here. In short, you should:

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:

Update your associations like:

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

by adding a 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>
like image 175
Nozim Turakulov Avatar answered Oct 16 '22 00:10

Nozim Turakulov