none
Error 3034: An entity from one EntitySet is mapped to a row that is also mapped to an entity from another EntitySet RRS feed

  • Question

  •  

    Hi,

     

    I've wasted all afternoon attempting to get the entity designer doing what I expect.  I have added a new inheritance level on most of my objects. Is very frustrating that every time you change a classes inheritance, the designer loses all that classes relationships.

     

    Eventually I thought I had it right, only to find a new problem which I haven't yet found a solution for.  I get this error when I build:

    Error 3034: Problem in Mapping Fragments starting at lines 2495, 2504: An entity from one EntitySet is mapped to a row that is also mapped to an entity from another EntitySet with possibly different key. Ensure these two mapping fragments do not map two unrelated EntitySets to two overlapping groups of rows.

    The code it is referring to is:

    Code Snippet

    <AssociationSetMapping Name="FK_Pictures_NextPicture" TypeName="bptour_DataModel.FK_Pictures_NextPicture" StoreEntitySet="Pictures">

    <EndProperty Name="Picture1">

    <ScalarProperty Name="TourObjectID" ColumnName="PictureID" />

    </EndProperty>

    <EndProperty Name="Picture">

    <ScalarProperty Name="TourObjectID" ColumnName="NextPictureID" />

    </EndProperty>

    <Condition ColumnName="NextPictureID" IsNull="false" />

    </AssociationSetMapping>

    <AssociationSetMapping Name="FK_Pictures_PrevPictures" TypeName="bptour_DataModel.FK_Pictures_PrevPictures" StoreEntitySet="Pictures">

    <EndProperty Name="Picture1">

    <ScalarProperty Name="TourObjectID" ColumnName="PictureID" />

    </EndProperty>

    <EndProperty Name="Picture">

    <ScalarProperty Name="TourObjectID" ColumnName="PrevPictureID" />

    </EndProperty>

    </AssociationSetMapping>

     

     

     

    And I have several similar associations with exactly the same problem, even though this problem did not exist even after changing the inheritance of that particular object.

     

    TourObjectID is the primary key defined in the parent class PictureID being the primary key in this particular class.

     

    Unfortunately I have been unable to come up with a solution to this particular problem, so I hope someone can point me in a direction, so I can actually work on my project again.

     

    ...Stefan

    Tuesday, August 26, 2008 6:42 AM

Answers

  • Hmm...could you try adding a condition to the second associationsetmapping?

    <Condition ColumnName="PrevPictureID" IsNull="false" />

     

    Not sure that will work, but its the first thing I'd try...
    Tuesday, August 26, 2008 2:56 PM
    Moderator

All replies

  • Hmm...could you try adding a condition to the second associationsetmapping?

    <Condition ColumnName="PrevPictureID" IsNull="false" />

     

    Not sure that will work, but its the first thing I'd try...
    Tuesday, August 26, 2008 2:56 PM
    Moderator
  •  

    Thank you so much!  That is the solution to the problem.

     

    The big question however, is why did the problem occur?  I've just tried to add that class to a new model.  When I discovered is that the condition is added in correctly.  It must have disappeared at some stage when I was doing the class inheritance.  Why is that?

     

    Thanks again!

     

    ...Stefan

    Tuesday, August 26, 2008 6:55 PM
  • I'm not sure how you got into this state, but as the designer is responsible for putting the condition in, I suspect there is some interaction here that the designer is not handling correctly. I'll forward this thread to the appropriate folks for review.

     

    Thanks,

      Noam

    Tuesday, August 26, 2008 7:33 PM
    Moderator
  •  

    I had the exact some issue and this solved it. I am using Entity Framework via Service Pack 1. The designer falls well short of the mark. I had to edit 2-3 things in the *.edmx file for each TPT sub entity or association. 

     

    Thank you!

    Tuesday, October 28, 2008 11:14 PM
  • I too experienced the same bug. After adding TPT inheritance to an existing EDM I had to edit the .edmx file by hand in several places. I had previously only used the Designer to modify the file. VS2008 SP1, .NET 3.5 SP1, Vista64, SqlExpress 2008.
    Tuesday, February 3, 2009 2:12 AM
  • Al salamo 3lycom
    please , I have the same problem but both properties are primary key then it is required to remove any conditions on the primary keys,what can i do?
    Tuesday, November 3, 2009 8:29 AM
  • Hi All,

    There is another situation where this error occurs and the message is not clear at all. We have an Entity that uses a non-nullable foreign key. For some reason the Multiplicity of the declaration was set to "0..1". This resulted in the error 3034 which, at the time, was not clear to us at all. Here's a code snippet of the wrong entry:

            <Association Name="FK_Dossier_DossierConsultationRelationship">
              <End Role="DossierConsultationRelationship" Type="KLIBNET2Model.Store.DossierConsultationRelationship" Multiplicity="0..1" />
              <End Role="Dossier" Type="KLIBNET2Model.Store.Dossier" Multiplicity="*" />
              <ReferentialConstraint>
                <Principal Role="DossierConsultationRelationship">
                  <PropertyRef Name="Id" />
                </Principal>
                <Dependent Role="Dossier">
                  <PropertyRef Name="DossierConsultationRelationshipId" />
                </Dependent>
              </ReferentialConstraint>
            </Association>


    Changing the Multiplicity on the DossierConsultationRelationship to "1" solved this problem.


            <Association Name="FK_Dossier_DossierConsultationRelationship">
              <End Role="DossierConsultationRelationship" Type="KLIBNET2Model.Store.DossierConsultationRelationship" Multiplicity="1" />
              <End Role="Dossier" Type="KLIBNET2Model.Store.Dossier" Multiplicity="*" />
              <ReferentialConstraint>
                <Principal Role="DossierConsultationRelationship">
                  <PropertyRef Name="Id" />
                </Principal>
                <Dependent Role="Dossier">
                  <PropertyRef Name="DossierConsultationRelationshipId" />
                </Dependent>
              </ReferentialConstraint>
            </Association>


    Regards,
    Paul Sinnema
    Take a look at my blog: http://paul.sinnema.ch
    Wednesday, November 25, 2009 8:17 AM