title: ADO EF - Errors Mapping Associations between Derived Types in TPH
body: <h2>Background</h2>
  
  <p>I am writing a data access library using the ADO Entity Framework in Visual Studio 2008 SP1 using the .NET Framework 3.5 SP1. I am trying to create associations between two entities that are both derived from an abstract type. I am representing both entity inheritance hierarchies using <a href="http://www.hibernate.org/hib_docs/reference/en/html/inheritance.html" rel="nofollow noreferrer">Table Per Hierarchy</a> (TPH) which means there are just two tables - one for each entity inheritance hierarchy. </p>
  
  <p><strong>NOTE</strong> You can use Table Per Type (TPT) to avoid this problem, but it comes with it's own drawbacks. See <a href="https://stackoverflow.com/questions/190296/how-do-you-effectively-model-inheritance-in-a-database">here</a> and <a href="http://blogs.microsoft.co.il/blogs/bursteg/archive/2007/09/30/how-to-model-inheritance-in-databases.aspx" rel="nofollow noreferrer">here</a> for more details when choosing between inheritance persistence models.</p>
  
  <p>Here is a screenshot of the Designer view of the Entity Model:</p>
  
  <p><a href="http://img153.imageshack.us/my.php?image=adoefgraphexamplescreenxz0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vgMgb.jpg" alt=" Design View of the Entity Model in Visual Studio 2008 SP1"></a>
  </p>
  
  <p>And here is a screenshot of the database schema:</p>
  
  <p><a href="http://img7.imageshack.us/my.php?image=graphexampledatabaseschik0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6lQWf.jpg" alt="Database Schema"></a>
  </p>
  
  <h2>Assumptions</h2>
  
  <p>When you create associations in the ADO Entity Framework Designer between derived types modeled with TPH using Visual Studio 2008 SP1 and the .NET Framework 3.5 SP1 you are likely to receive the following an "Error 3034: Two entities with different keys are mapped to the same row. Ensure these two mapping fragments do no map two groups of entities with overlapping keys to the same group of rows."</p>
  
  <p>Based on what I have <a href="http://social.msdn.microsoft.com/forums/en-US/adodotnetentityframework/thread/12191f0d-3010-425d-9c52-ed0542458eaf/" rel="nofollow noreferrer">read online</a>, in order to resolve this issue, you must add a Condition to the association on the Foreign Key like so:</p>
  
  <pre><code>&lt;Condition ColumnName="Endpoint1" IsNull="false" /&gt;
  </code></pre>
  
  <p>Here's a screenshot of this edit for the PersonPersonToPerson1 association:</p>
  
  <p><a href="http://img153.imageshack.us/my.php?image=edmxassociationsetmappiah8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/neseQ.jpg" alt=" Visual Studio 2008 SP1 Editing of GraphModel.edmx"></a>
  </p>
  
  <h2>Constraints</h2>
  
  <ul>
  <li>The base classes of each hierarchy (i.e. Node and Link) <em>must</em> be abstract.</li>
  <li>The navigation properties from the associations between two derived types <em>must</em> be distinguishable by link type (e.g. PersonToPerson and PersonToLocation). This means you <em>cannot</em> create the associations between the Link and Node abstract base classes.</li>
  </ul>
  
  <h2>Problem:</h2>
  
  <p>When I create the Entity Model as described above and add the Conditions to the AssociationMappings as described in the Assumptions above, I receive an "Error 3023" when I build/validate the model.</p>
  
  <pre><code>Error   1   Error 3023: Problem in Mapping Fragments starting at lines 146, 153, 159, 186, 195, 204, 213: Column Link.Endpoint1 has no default value and is not nullable. A column value is required to store entity data.
  An Entity with Key (PK) will not round-trip when:
  ((PK is NOT in 'LinkSet' EntitySet OR PK does NOT play Role 'PersonToPerson' in AssociationSet 'PersonPersonToPerson1') AND (PK is in 'LinkSet' EntitySet OR PK plays Role 'PersonToPerson' in AssociationSet 'PersonPersonToPerson1' OR PK plays Role 'PersonToPerson' in AssociationSet 'PersonPersonToPerson'))
  C:\Documents and Settings\Demo\My Documents\Visual Studio 2008\Projects\GraphExample2.BusinessEntities\GraphExample2.BusinessEntities\GraphModel.edmx   147 15  GraphExample2.BusinessEntities
  </code></pre>
  
  <p>The thing that the Entity Framework is getting hung up on in the above scenario is that there are two properties being mapped on to the same foreign keys. For example, the column and foreign key for Endpoint1 is mapped to the Person property in the PersonToLocation derived type and it's mapped to the Leader property in the PersonToPerson derived type.</p>
  
  <p>I don't understand why this is an issue. Since the Leader/Follower Properties are only in the PersonToPerson derived type - not any other derived type or base type - and the same is true of the Person/Location property, why isn't the TypeDiscriminator field sufficient for the EF to figure out which set a given row belongs in?</p>
  
  <p>To me it seems like, if you are dealing with an object where TypeDiscriminator = 1, you place Endpoint1 in Leader and Endpoint2 in Follower. Likewise, if you are dealing with an object where TypeDiscriminator = 2, you place Endpoint1 in Person and Endpoint2 in Location.</p>
  
  <h2>Question:</h2>
  
  <p><strong>How do you resolve the Error 3023 to allow these associations to occur ?</strong></p>
  
  <p>OR</p>
  
  <p><strong>How do you create the type of associations in the ADO Entity Framework that I have described above?</strong></p>
  
  <h2>References:</h2>
  
  <ul>
  <li>MSDN Forum - <a href="http://social.msdn.microsoft.com/forums/en-US/adodotnetentityframework/thread/4aa46c4a-05d5-49e7-82ef-33b79904fcc9/" rel="nofollow noreferrer">Error 3034: Problem in Mapping Fragments starting at lines ...</a></li>
  <li>Zeeshan Hirani's Blog - <a href="http://weblogs.asp.net/zeeshanhirani/archive/2008/12/05/my-christmas-present-to-the-entity-framework-community.aspx" rel="nofollow noreferrer">Contributions to Entity framework community</a></li>
  <li>Zeeshan Hirani's <a href="http://cid-245ed00edb4c374e.skydrive.live.com/self.aspx/Public/entity%20framework%20learning%20guide.pdf" rel="nofollow noreferrer">Entity Framework learning guide</a> (this is an Excellent 514 page step-by-step guide to numerous concepts and gotchas with ADO EF. HIGHLY recommended!)</li>
  </ul>
  
  <h2>Code</h2>
  
  <p>SQL:</p>
  
  <pre><code>USE [GraphExample2]
  GO
  /****** Object:  Table [dbo].[Node]    Script Date: 02/17/2009 14:36:13 ******/
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  SET ANSI_PADDING ON
  GO
  CREATE TABLE [dbo].[Node](
      [NodeID] [int] NOT NULL,
      [NodeTypeDiscriminator] [int] NOT NULL,
      [Name] [varchar](255) NOT NULL,
      [Description] [varchar](1023) NULL,
   CONSTRAINT [PK_Node] PRIMARY KEY CLUSTERED 
  (
      [NodeID] ASC
  )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
  ) ON [PRIMARY]
  GO
  SET ANSI_PADDING OFF
  GO
  /****** Object:  Table [dbo].[Link]    Script Date: 02/17/2009 14:36:12 ******/
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  SET ANSI_PADDING ON
  GO
  CREATE TABLE [dbo].[Link](
      [LinkID] [int] NOT NULL,
      [LinkTypeDiscriminator] [int] NOT NULL,
      [Endpoint1] [int] NOT NULL,
      [Endpoint2] [int] NOT NULL,
      [Name] [varchar](255) NULL,
      [Description] [varchar](1023) NULL,
   CONSTRAINT [PK_Link] PRIMARY KEY CLUSTERED 
  (
      [LinkID] ASC
  )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
  ) ON [PRIMARY]
  GO
  SET ANSI_PADDING OFF
  GO
  /****** Object:  ForeignKey [FK_Link_Node_Endpoint1]    Script Date: 02/17/2009 14:36:12 ******/
  ALTER TABLE [dbo].[Link]  WITH CHECK ADD  CONSTRAINT [FK_Link_Node_Endpoint1] FOREIGN KEY([Endpoint1])
  REFERENCES [dbo].[Node] ([NodeID])
  GO
  ALTER TABLE [dbo].[Link] CHECK CONSTRAINT [FK_Link_Node_Endpoint1]
  GO
  /****** Object:  ForeignKey [FK_Link_Node_Endpoint2]    Script Date: 02/17/2009 14:36:12 ******/
  ALTER TABLE [dbo].[Link]  WITH CHECK ADD  CONSTRAINT [FK_Link_Node_Endpoint2] FOREIGN KEY([Endpoint2])
  REFERENCES [dbo].[Node] ([NodeID])
  GO
  ALTER TABLE [dbo].[Link] CHECK CONSTRAINT [FK_Link_Node_Endpoint2]
  GO
  </code></pre>
  
  <p>EDMX:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx"&gt;
    &lt;!-- EF Runtime content --&gt;
    &lt;edmx:Runtime&gt;
      &lt;!-- SSDL content --&gt;
      &lt;edmx:StorageModels&gt;
        &lt;Schema Namespace="GraphModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2005" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2006/04/edm/ssdl"&gt;
          &lt;EntityContainer Name="GraphModelStoreContainer"&gt;
            &lt;EntitySet Name="Link" EntityType="GraphModel.Store.Link" store:Type="Tables" Schema="dbo" /&gt;
            &lt;EntitySet Name="Node" EntityType="GraphModel.Store.Node" store:Type="Tables" Schema="dbo" /&gt;
            &lt;AssociationSet Name="FK_Link_Node_Endpoint1" Association="GraphModel.Store.FK_Link_Node_Endpoint1"&gt;
              &lt;End Role="Node" EntitySet="Node" /&gt;
              &lt;End Role="Link" EntitySet="Link" /&gt;
            &lt;/AssociationSet&gt;
            &lt;AssociationSet Name="FK_Link_Node_Endpoint2" Association="GraphModel.Store.FK_Link_Node_Endpoint2"&gt;
              &lt;End Role="Node" EntitySet="Node" /&gt;
              &lt;End Role="Link" EntitySet="Link" /&gt;
            &lt;/AssociationSet&gt;
          &lt;/EntityContainer&gt;
          &lt;EntityType Name="Link"&gt;
            &lt;Key&gt;
              &lt;PropertyRef Name="LinkID" /&gt;
            &lt;/Key&gt;
            &lt;Property Name="LinkID" Type="int" Nullable="false" /&gt;
            &lt;Property Name="LinkTypeDiscriminator" Type="int" Nullable="false" /&gt;
            &lt;Property Name="Endpoint1" Type="int" Nullable="false" /&gt;
            &lt;Property Name="Endpoint2" Type="int" Nullable="false" /&gt;
            &lt;Property Name="Name" Type="varchar" MaxLength="255" /&gt;
            &lt;Property Name="Description" Type="varchar" MaxLength="1023" /&gt;
          &lt;/EntityType&gt;
          &lt;EntityType Name="Node"&gt;
            &lt;Key&gt;
              &lt;PropertyRef Name="NodeID" /&gt;
            &lt;/Key&gt;
            &lt;Property Name="NodeID" Type="int" Nullable="false" /&gt;
            &lt;Property Name="NodeTypeDiscriminator" Type="int" Nullable="false" /&gt;
            &lt;Property Name="Name" Type="varchar" Nullable="false" MaxLength="255" /&gt;
            &lt;Property Name="Description" Type="varchar" MaxLength="1023" /&gt;
          &lt;/EntityType&gt;
          &lt;Association Name="FK_Link_Node_Endpoint1"&gt;
            &lt;End Role="Node" Type="GraphModel.Store.Node" Multiplicity="1" /&gt;
            &lt;End Role="Link" Type="GraphModel.Store.Link" Multiplicity="*" /&gt;
            &lt;ReferentialConstraint&gt;
              &lt;Principal Role="Node"&gt;
                &lt;PropertyRef Name="NodeID" /&gt;
              &lt;/Principal&gt;
              &lt;Dependent Role="Link"&gt;
                &lt;PropertyRef Name="Endpoint1" /&gt;
              &lt;/Dependent&gt;
            &lt;/ReferentialConstraint&gt;
          &lt;/Association&gt;
          &lt;Association Name="FK_Link_Node_Endpoint2"&gt;
            &lt;End Role="Node" Type="GraphModel.Store.Node" Multiplicity="1" /&gt;
            &lt;End Role="Link" Type="GraphModel.Store.Link" Multiplicity="*" /&gt;
            &lt;ReferentialConstraint&gt;
              &lt;Principal Role="Node"&gt;
                &lt;PropertyRef Name="NodeID" /&gt;
              &lt;/Principal&gt;
              &lt;Dependent Role="Link"&gt;
                &lt;PropertyRef Name="Endpoint2" /&gt;
              &lt;/Dependent&gt;
            &lt;/ReferentialConstraint&gt;
          &lt;/Association&gt;
        &lt;/Schema&gt;
      &lt;/edmx:StorageModels&gt;
      &lt;!-- CSDL content --&gt;
      &lt;edmx:ConceptualModels&gt;
        &lt;Schema xmlns="http://schemas.microsoft.com/ado/2006/04/edm" Namespace="GraphModel" Alias="Self"&gt;
          &lt;EntityContainer Name="GraphModelContainer" &gt;
            &lt;EntitySet Name="NodeSet" EntityType="GraphModel.Node" /&gt;
            &lt;EntitySet Name="LinkSet" EntityType="GraphModel.Link" /&gt;
            &lt;AssociationSet Name="PersonPersonToPerson" Association="GraphModel.PersonPersonToPerson"&gt;
              &lt;End Role="Person" EntitySet="NodeSet" /&gt;
              &lt;End Role="PersonToPerson" EntitySet="LinkSet" /&gt;
            &lt;/AssociationSet&gt;
            &lt;AssociationSet Name="PersonPersonToPerson1" Association="GraphModel.PersonPersonToPerson1"&gt;
              &lt;End Role="Person" EntitySet="NodeSet" /&gt;
              &lt;End Role="PersonToPerson" EntitySet="LinkSet" /&gt;
            &lt;/AssociationSet&gt;
            &lt;AssociationSet Name="Person_PersonToLocation" Association="GraphModel.Person_PersonToLocation"&gt;
              &lt;End Role="Person" EntitySet="NodeSet" /&gt;
              &lt;End Role="PersonToLocation" EntitySet="LinkSet" /&gt;
            &lt;/AssociationSet&gt;
            &lt;AssociationSet Name="Location_PersonToLocation" Association="GraphModel.Location_PersonToLocation"&gt;
              &lt;End Role="Location" EntitySet="NodeSet" /&gt;
              &lt;End Role="PersonToLocation" EntitySet="LinkSet" /&gt;
            &lt;/AssociationSet&gt;
          &lt;/EntityContainer&gt;
          &lt;EntityType Name="Node" Abstract="true"&gt;
            &lt;Key&gt;
              &lt;PropertyRef Name="NodeId" /&gt;
            &lt;/Key&gt;
            &lt;Property Name="NodeId" Type="Int32" Nullable="false" /&gt;
            &lt;Property Name="Name" Type="String" Nullable="false" /&gt;
            &lt;Property Name="Description" Type="String" Nullable="true" /&gt;
          &lt;/EntityType&gt;
          &lt;EntityType Name="Person" BaseType="GraphModel.Node" &gt;
            &lt;NavigationProperty Name="Leaders" Relationship="GraphModel.PersonPersonToPerson" FromRole="Person" ToRole="PersonToPerson" /&gt;
            &lt;NavigationProperty Name="Followers" Relationship="GraphModel.PersonPersonToPerson1" FromRole="Person" ToRole="PersonToPerson" /&gt;
            &lt;NavigationProperty Name="Locations" Relationship="GraphModel.Person_PersonToLocation" FromRole="Person" ToRole="PersonToLocation" /&gt;
          &lt;/EntityType&gt;
          &lt;EntityType Name="Location" BaseType="GraphModel.Node" &gt;
            &lt;NavigationProperty Name="Visitors" Relationship="GraphModel.Location_PersonToLocation" FromRole="Location" ToRole="PersonToLocation" /&gt;
          &lt;/EntityType&gt;
          &lt;EntityType Name="Link" Abstract="true"&gt;
            &lt;Key&gt;
              &lt;PropertyRef Name="LinkId" /&gt;
            &lt;/Key&gt;
            &lt;Property Name="LinkId" Type="Int32" Nullable="false" /&gt;
            &lt;Property Name="Name" Type="String" Nullable="true" /&gt;
            &lt;Property Name="Description" Type="String" Nullable="true" /&gt;
          &lt;/EntityType&gt;
          &lt;EntityType Name="PersonToPerson" BaseType="GraphModel.Link" &gt;
            &lt;NavigationProperty Name="Leader" Relationship="GraphModel.PersonPersonToPerson" FromRole="PersonToPerson" ToRole="Person" /&gt;
            &lt;NavigationProperty Name="Follower" Relationship="GraphModel.PersonPersonToPerson1" FromRole="PersonToPerson" ToRole="Person" /&gt;
          &lt;/EntityType&gt;
          &lt;EntityType Name="PersonToLocation" BaseType="GraphModel.Link" &gt;
            &lt;NavigationProperty Name="Person" Relationship="GraphModel.Person_PersonToLocation" FromRole="PersonToLocation" ToRole="Person" /&gt;
            &lt;NavigationProperty Name="Location" Relationship="GraphModel.Location_PersonToLocation" FromRole="PersonToLocation" ToRole="Location" /&gt;
          &lt;/EntityType&gt;
          &lt;Association Name="PersonPersonToPerson"&gt;
            &lt;End Type="GraphModel.Person" Role="Person" Multiplicity="1" /&gt;
            &lt;End Type="GraphModel.PersonToPerson" Role="PersonToPerson" Multiplicity="*" /&gt;
          &lt;/Association&gt;
          &lt;Association Name="PersonPersonToPerson1"&gt;
            &lt;End Type="GraphModel.Person" Role="Person" Multiplicity="1" /&gt;
            &lt;End Type="GraphModel.PersonToPerson" Role="PersonToPerson" Multiplicity="*" /&gt;
          &lt;/Association&gt;
          &lt;Association Name="Person_PersonToLocation"&gt;
            &lt;End Type="GraphModel.Person" Role="Person" Multiplicity="1" /&gt;
            &lt;End Type="GraphModel.PersonToLocation" Role="PersonToLocation" Multiplicity="*" /&gt;
          &lt;/Association&gt;
          &lt;Association Name="Location_PersonToLocation"&gt;
            &lt;End Type="GraphModel.Location" Role="Location" Multiplicity="1" /&gt;
            &lt;End Type="GraphModel.PersonToLocation" Role="PersonToLocation" Multiplicity="*" /&gt;
          &lt;/Association&gt;
        &lt;/Schema&gt;
      &lt;/edmx:ConceptualModels&gt;
      &lt;!-- C-S mapping content --&gt;
      &lt;edmx:Mappings&gt;
        &lt;Mapping xmlns="urn:schemas-microsoft-com:windows:storage:mapping:CS" Space="C-S"&gt;
          &lt;Alias Key="Model" Value="GraphModel" /&gt;
          &lt;Alias Key="Target" Value="GraphModel.Store" /&gt;
          &lt;EntityContainerMapping CdmEntityContainer="GraphModelContainer" StorageEntityContainer="GraphModelStoreContainer"&gt;
            &lt;EntitySetMapping Name="LinkSet"&gt;
              &lt;EntityTypeMapping TypeName="IsTypeOf(GraphModel.Link)"&gt;
                &lt;MappingFragment StoreEntitySet="Link"&gt;
                  &lt;ScalarProperty Name="Description" ColumnName="Description" /&gt;
                  &lt;ScalarProperty Name="Name" ColumnName="Name" /&gt;
                  &lt;ScalarProperty Name="LinkId" ColumnName="LinkID" /&gt;
                &lt;/MappingFragment&gt;
              &lt;/EntityTypeMapping&gt;
              &lt;EntityTypeMapping TypeName="IsTypeOf(GraphModel.PersonToPerson)"&gt;
                &lt;MappingFragment StoreEntitySet="Link" &gt;
                  &lt;ScalarProperty Name="LinkId" ColumnName="LinkID" /&gt;
                  &lt;Condition ColumnName="LinkTypeDiscriminator" Value="1" /&gt;
                &lt;/MappingFragment&gt;
              &lt;/EntityTypeMapping&gt;
              &lt;EntityTypeMapping TypeName="IsTypeOf(GraphModel.PersonToLocation)"&gt;
                &lt;MappingFragment StoreEntitySet="Link" &gt;
                  &lt;ScalarProperty Name="LinkId" ColumnName="LinkID" /&gt;
                  &lt;Condition ColumnName="LinkTypeDiscriminator" Value="2" /&gt;
                &lt;/MappingFragment&gt;
              &lt;/EntityTypeMapping&gt;
            &lt;/EntitySetMapping&gt;
            &lt;EntitySetMapping Name="NodeSet"&gt;
              &lt;EntityTypeMapping TypeName="IsTypeOf(GraphModel.Node)"&gt;
                &lt;MappingFragment StoreEntitySet="Node"&gt;
                  &lt;ScalarProperty Name="Description" ColumnName="Description" /&gt;
                  &lt;ScalarProperty Name="Name" ColumnName="Name" /&gt;
                  &lt;ScalarProperty Name="NodeId" ColumnName="NodeID" /&gt;
                &lt;/MappingFragment&gt;
              &lt;/EntityTypeMapping&gt;
              &lt;EntityTypeMapping TypeName="IsTypeOf(GraphModel.Person)"&gt;
                &lt;MappingFragment StoreEntitySet="Node" &gt;
                  &lt;ScalarProperty Name="NodeId" ColumnName="NodeID" /&gt;
                  &lt;Condition ColumnName="NodeTypeDiscriminator" Value="1" /&gt;
                &lt;/MappingFragment&gt;
              &lt;/EntityTypeMapping&gt;
              &lt;EntityTypeMapping TypeName="IsTypeOf(GraphModel.Location)"&gt;
                &lt;MappingFragment StoreEntitySet="Node" &gt;
                  &lt;ScalarProperty Name="NodeId" ColumnName="NodeID" /&gt;
                  &lt;Condition ColumnName="NodeTypeDiscriminator" Value="2" /&gt;
                &lt;/MappingFragment&gt;
              &lt;/EntityTypeMapping&gt;
            &lt;/EntitySetMapping&gt;
            &lt;AssociationSetMapping Name="PersonPersonToPerson1" TypeName="GraphModel.PersonPersonToPerson1" StoreEntitySet="Link"&gt;
              &lt;EndProperty Name="Person"&gt;
                &lt;ScalarProperty Name="NodeId" ColumnName="Endpoint1" /&gt;
              &lt;/EndProperty&gt;
              &lt;EndProperty Name="PersonToPerson"&gt;
                &lt;ScalarProperty Name="LinkId" ColumnName="LinkID" /&gt;
              &lt;/EndProperty&gt;
              &lt;Condition ColumnName="Endpoint1" IsNull="false" /&gt;
            &lt;/AssociationSetMapping&gt;
            &lt;AssociationSetMapping Name="PersonPersonToPerson" TypeName="GraphModel.PersonPersonToPerson" StoreEntitySet="Link"&gt;
              &lt;EndProperty Name="Person"&gt;
                &lt;ScalarProperty Name="NodeId" ColumnName="Endpoint2" /&gt;
              &lt;/EndProperty&gt;
              &lt;EndProperty Name="PersonToPerson"&gt;
                &lt;ScalarProperty Name="LinkId" ColumnName="LinkID" /&gt;
              &lt;/EndProperty&gt;
              &lt;Condition ColumnName="Endpoint2" IsNull="false" /&gt;
            &lt;/AssociationSetMapping&gt;
            &lt;AssociationSetMapping Name="Person_PersonToLocation" TypeName="GraphModel.Person_PersonToLocation" StoreEntitySet="Link"&gt;
              &lt;EndProperty Name="Person"&gt;
                &lt;ScalarProperty Name="NodeId" ColumnName="Endpoint1" /&gt;
              &lt;/EndProperty&gt;
              &lt;EndProperty Name="PersonToLocation"&gt;
                &lt;ScalarProperty Name="LinkId" ColumnName="LinkID" /&gt;
              &lt;/EndProperty&gt;
              &lt;Condition ColumnName="Endpoint1" IsNull="false" /&gt;
            &lt;/AssociationSetMapping&gt;
            &lt;AssociationSetMapping Name="Location_PersonToLocation" TypeName="GraphModel.Location_PersonToLocation" StoreEntitySet="Link"&gt;
              &lt;EndProperty Name="Location"&gt;
                &lt;ScalarProperty Name="NodeId" ColumnName="Endpoint2" /&gt;
              &lt;/EndProperty&gt;
              &lt;EndProperty Name="PersonToLocation"&gt;
                &lt;ScalarProperty Name="LinkId" ColumnName="LinkID" /&gt;
              &lt;/EndProperty&gt;
              &lt;Condition ColumnName="Endpoint2" IsNull="false" /&gt;
            &lt;/AssociationSetMapping&gt;
          &lt;/EntityContainerMapping&gt;
        &lt;/Mapping&gt;
      &lt;/edmx:Mappings&gt;
    &lt;/edmx:Runtime&gt;
    &lt;!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) --&gt;
    &lt;edmx:Designer xmlns="http://schemas.microsoft.com/ado/2007/06/edmx"&gt;
      &lt;edmx:Connection&gt;
        &lt;DesignerInfoPropertySet&gt;
          &lt;DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" /&gt;
        &lt;/DesignerInfoPropertySet&gt;
      &lt;/edmx:Connection&gt;
      &lt;edmx:Options&gt;
        &lt;DesignerInfoPropertySet&gt;
          &lt;DesignerProperty Name="ValidateOnBuild" Value="true" /&gt;
        &lt;/DesignerInfoPropertySet&gt;
      &lt;/edmx:Options&gt;
      &lt;!-- Diagram content (shape and connector positions) --&gt;
      &lt;edmx:Diagrams&gt;
        &lt;Diagram Name="GraphModel" ZoomLevel="114" &gt;
          &lt;EntityTypeShape EntityType="GraphModel.Node" Width="1.5" PointX="5.875" PointY="1.375" Height="1.427958984375" /&gt;
          &lt;EntityTypeShape EntityType="GraphModel.Person" Width="1.5" PointX="5.875" PointY="3.25" Height="1.4279589843749996" /&gt;
          &lt;EntityTypeShape EntityType="GraphModel.Location" Width="1.5" PointX="7.75" PointY="4.625" Height="1.0992643229166665" /&gt;
          &lt;InheritanceConnector EntityType="GraphModel.Location"&gt;
            &lt;ConnectorPoint PointX="7.375" PointY="2.0889794921875" /&gt;
            &lt;ConnectorPoint PointX="8.5" PointY="2.0889794921875" /&gt;
            &lt;ConnectorPoint PointX="8.5" PointY="4.625" /&gt;
          &lt;/InheritanceConnector&gt;
          &lt;EntityTypeShape EntityType="GraphModel.Link" Width="1.5" PointX="2.875" PointY="1.375" Height="1.427958984375" /&gt;
          &lt;EntityTypeShape EntityType="GraphModel.PersonToPerson" Width="1.75" PointX="2.625" PointY="3.125" Height="0.9349169921875" /&gt;
          &lt;InheritanceConnector EntityType="GraphModel.PersonToPerson"&gt;
            &lt;ConnectorPoint PointX="3.625" PointY="2.802958984375" /&gt;
            &lt;ConnectorPoint PointX="3.625" PointY="3.125" /&gt;
          &lt;/InheritanceConnector&gt;
          &lt;InheritanceConnector EntityType="GraphModel.Person"&gt;
            &lt;ConnectorPoint PointX="6.625" PointY="2.802958984375" /&gt;
            &lt;ConnectorPoint PointX="6.625" PointY="3.25" /&gt;
          &lt;/InheritanceConnector&gt;
          &lt;EntityTypeShape EntityType="GraphModel.PersonToLocation" Width="1.875" PointX="0.75" PointY="4.625" Height="1.2636116536458326" /&gt;
          &lt;InheritanceConnector EntityType="GraphModel.PersonToLocation"&gt;
            &lt;ConnectorPoint PointX="2.875" PointY="2.0889794921875" /&gt;
            &lt;ConnectorPoint PointX="1.65625" PointY="2.0889794921875" /&gt;
            &lt;ConnectorPoint PointX="1.65625" PointY="4.625" /&gt;
          &lt;/InheritanceConnector&gt;
          &lt;AssociationConnector Association="GraphModel.PersonPersonToPerson"&gt;
            &lt;ConnectorPoint PointX="5.875" PointY="3.8193058268229163" /&gt;
            &lt;ConnectorPoint PointX="4.375" PointY="3.8193058268229163" /&gt;
          &lt;/AssociationConnector&gt;
          &lt;AssociationConnector Association="GraphModel.PersonPersonToPerson1"&gt;
            &lt;ConnectorPoint PointX="5.875" PointY="3.4721529134114579" /&gt;
            &lt;ConnectorPoint PointX="4.375" PointY="3.4721529134114579" /&gt;
          &lt;/AssociationConnector&gt;
          &lt;AssociationConnector Association="GraphModel.Person_PersonToLocation"&gt;
            &lt;ConnectorPoint PointX="6.625" PointY="4.677958984375" /&gt;
            &lt;ConnectorPoint PointX="6.625" PointY="5.1875" /&gt;
            &lt;ConnectorPoint PointX="2.625" PointY="5.1875" /&gt;
          &lt;/AssociationConnector&gt;
          &lt;AssociationConnector Association="GraphModel.Location_PersonToLocation"&gt;
            &lt;ConnectorPoint PointX="7.75" PointY="5.4791666666666661" /&gt;
            &lt;ConnectorPoint PointX="2.625" PointY="5.4791666666666661" /&gt;
          &lt;/AssociationConnector&gt;
        &lt;/Diagram&gt;
      &lt;/edmx:Diagrams&gt;
    &lt;/edmx:Designer&gt;
  &lt;/edmx:Edmx&gt;
  </code></pre>