0
votes

I am developing MVC Application with EF 4.1. I have used TPH approch to generate the DB.

I have two entities, 1. company and 2. Lead , Lead is inherited from Company.

please check below image:

enter image description here

Now I have below mappaings...

enter image description here

here is edmx file with XML

<EntitySetMapping Name="Companies">
            <EntityTypeMapping TypeName="IsTypeOf(Model1.Company)">
                <MappingFragment StoreEntitySet="Companies">
                    <ScalarProperty Name="Id" ColumnName="Id" />
                    <ScalarProperty Name="Name" ColumnName="Name" />
          <Condition ColumnName="__Disc__" Value="Company" />
                </MappingFragment>
            </EntityTypeMapping>
            <EntityTypeMapping TypeName="Model1.Lead">
                <MappingFragment StoreEntitySet="Companies">
    // Gives Error ->   <ScalarProperty Name="Id" ColumnName="Id" />
    // Gives Error ->   <ScalarProperty Name="Name" ColumnName="Name" />
    // Gives Error ->   <ScalarProperty Name="Status" ColumnName="Status" />
                    <Condition ColumnName="__Disc__" Value="Lead" />
                </MappingFragment>
            </EntityTypeMapping>

Error 3034: Problem in mapping fragments starting at lines 47, 54:An entity is mapped to different rows within the same table. Ensure these two mapping fragments do not map two groups of entities with identical keys to two distinct groups of rows.

1

1 Answers

0
votes

Problem Solved. Removed discrimitor property from the base entity in edmx.