title: How to do a simple join with entity framework data model designer?
body: <p>I tried this:
  <a href="http://channel9.msdn.com/posts/RobBagby/deCast-Entity-Framework-Modeling-Implementing-Entity-Splitting/Default.aspx?wa=wsignin1.0" rel="nofollow noreferrer">http://channel9.msdn.com/posts/RobBagby/deCast-Entity-Framework-Modeling-Implementing-Entity-Splitting/Default.aspx?wa=wsignin1.0</a></p>
  
  <p>...with the Northwind sample database from Codeplex, using the Employee and Contact tables.  I wanted to create a EmployeeContact entity that basically pulls in the FirstName and LastName columns from the Contact.  So I copied and pasted these properties and the ContactID property from the Contact entity to the Employee entity.  I mapped all of these but I now get an error about mapping the EmployeeID property:</p>
  
  <p>"Error 3024: Problem in mapping fragments starting at line 389:Must specify mapping for all key properties (Employees.EmployeeID) of the EntitySet Employees."</p>
  
  <p>And for that matter, how do I get VS to show me the markup for the mapping file instead of showing me the designer?  At least maybe then I could begin to see the source of the error since it references a specific line number.</p>
  
  <p>This property is mapped, in that the Mapping Details view shows an assignment from table column to entity property of the same name, which was already generated that way for me.  It took me a good bit to get to this point, and it is frustrating that creating what would normally be a simple join is so problematic.  I hate to imagine the problems one runs in to doing anything even slightly more complex. </p>
  
  <p>I'm sure someone will suggest I use LINQ, but I thought the whole purpose of the Entity Framework was to make it so you thought more about the meaning of data and less about the relational structure?  In other words, not having to do numerous joins everytime you wanted a simple set of data.</p>
  
  <p>Thanks in advance.</p>
  
  <p>Here is me edmx file, I have stripped down the mappings section to try and get it to compile:</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="AdventureWorksModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2008" 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="AdventureWorksModelStoreContainer"&gt;
            &lt;EntitySet Name="Employee" EntityType="AdventureWorksModel.Store.Employee" store:Type="Tables" Schema="HumanResources" /&gt;
            &lt;EntitySet Name="Contact" EntityType="AdventureWorksModel.Store.Contact" Schema="Person" store:Type="Tables" /&gt;
            &lt;AssociationSet Name="FK_Employee_Contact_ContactID" Association="AdventureWorksModel.Store.FK_Employee_Contact_ContactID"&gt;
              &lt;End EntitySet="Contact" Role="Contact" /&gt;
              &lt;End EntitySet="Employee" Role="Employee" /&gt;
            &lt;/AssociationSet&gt;
            &lt;AssociationSet Name="FK_Employee_Employee_ManagerID" Association="AdventureWorksModel.Store.FK_Employee_Employee_ManagerID"&gt;
              &lt;End Role="Employee" EntitySet="Employee" /&gt;
              &lt;End Role="Employee1" EntitySet="Employee" /&gt;
            &lt;/AssociationSet&gt;
          &lt;/EntityContainer&gt;
          &lt;EntityType Name="Employee"&gt;
            &lt;Key&gt;
              &lt;PropertyRef Name="EmployeeID" /&gt;
            &lt;/Key&gt;
            &lt;Property Name="EmployeeID" Type="int" Nullable="false" StoreGeneratedPattern="Identity" /&gt;
            &lt;Property Name="NationalIDNumber" Type="nvarchar" Nullable="false" MaxLength="15" /&gt;
            &lt;Property Name="ContactID" Type="int" Nullable="false" /&gt;
            &lt;Property Name="LoginID" Type="nvarchar" Nullable="false" MaxLength="256" /&gt;
            &lt;Property Name="ManagerID" Type="int" /&gt;
            &lt;Property Name="Title" Type="nvarchar" Nullable="false" MaxLength="50" /&gt;
            &lt;Property Name="BirthDate" Type="datetime" Nullable="false" /&gt;
            &lt;Property Name="MaritalStatus" Type="nchar" Nullable="false" MaxLength="1" /&gt;
            &lt;Property Name="Gender" Type="nchar" Nullable="false" MaxLength="1" /&gt;
            &lt;Property Name="HireDate" Type="datetime" Nullable="false" /&gt;
            &lt;Property Name="SalariedFlag" Type="bit" Nullable="false" /&gt;
            &lt;Property Name="VacationHours" Type="smallint" Nullable="false" /&gt;
            &lt;Property Name="SickLeaveHours" Type="smallint" Nullable="false" /&gt;
            &lt;Property Name="CurrentFlag" Type="bit" Nullable="false" /&gt;
            &lt;Property Name="rowguid" Type="uniqueidentifier" Nullable="false" /&gt;
            &lt;Property Name="ModifiedDate" Type="datetime" Nullable="false" /&gt;
          &lt;/EntityType&gt;
          &lt;EntityType Name="Contact"&gt;
            &lt;Key&gt;
              &lt;PropertyRef Name="ContactID" /&gt;
            &lt;/Key&gt;
            &lt;Property StoreGeneratedPattern="Identity" Name="ContactID" Nullable="false" Type="int" /&gt;
            &lt;Property Name="NameStyle" Nullable="false" Type="bit" /&gt;
            &lt;Property Name="Title" MaxLength="8" Type="nvarchar" /&gt;
            &lt;Property Name="FirstName" Nullable="false" MaxLength="50" Type="nvarchar" /&gt;
            &lt;Property Name="MiddleName" MaxLength="50" Type="nvarchar" /&gt;
            &lt;Property Name="LastName" Nullable="false" MaxLength="50" Type="nvarchar" /&gt;
            &lt;Property Name="Suffix" MaxLength="10" Type="nvarchar" /&gt;
            &lt;Property Name="EmailAddress" MaxLength="50" Type="nvarchar" /&gt;
            &lt;Property Name="EmailPromotion" Nullable="false" Type="int" /&gt;
            &lt;Property Name="Phone" MaxLength="25" Type="nvarchar" /&gt;
            &lt;Property Name="PasswordHash" Nullable="false" MaxLength="128" Type="varchar" /&gt;
            &lt;Property Name="PasswordSalt" Nullable="false" MaxLength="10" Type="varchar" /&gt;
            &lt;Property Name="AdditionalContactInfo" Type="xml" /&gt;
            &lt;Property Name="rowguid" Nullable="false" Type="uniqueidentifier" /&gt;
            &lt;Property Name="ModifiedDate" Nullable="false" Type="datetime" /&gt;
          &lt;/EntityType&gt;
          &lt;Association Name="FK_Employee_Contact_ContactID"&gt;
            &lt;End Type="AdventureWorksModel.Store.Contact" Multiplicity="1" Role="Contact" /&gt;
            &lt;End Type="AdventureWorksModel.Store.Employee" Multiplicity="*" Role="Employee" /&gt;
            &lt;ReferentialConstraint&gt;
              &lt;Principal Role="Contact"&gt;
                &lt;PropertyRef Name="ContactID" /&gt;
              &lt;/Principal&gt;
              &lt;Dependent Role="Employee"&gt;
                &lt;PropertyRef Name="ContactID" /&gt;
              &lt;/Dependent&gt;
            &lt;/ReferentialConstraint&gt;
          &lt;/Association&gt;
          &lt;Association Name="FK_Employee_Employee_ManagerID"&gt;
            &lt;End Role="Employee" Type="AdventureWorksModel.Store.Employee" Multiplicity="0..1" /&gt;
            &lt;End Role="Employee1" Type="AdventureWorksModel.Store.Employee" Multiplicity="*" /&gt;
            &lt;ReferentialConstraint&gt;
              &lt;Principal Role="Employee"&gt;
                &lt;PropertyRef Name="EmployeeID" /&gt;
              &lt;/Principal&gt;
              &lt;Dependent Role="Employee1"&gt;
                &lt;PropertyRef Name="ManagerID" /&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 Namespace="AdventureWorksModel" Alias="Self" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns="http://schemas.microsoft.com/ado/2006/04/edm"&gt;
          &lt;EntityContainer Name="AdventureWorksEntities"&gt;
            &lt;EntitySet Name="EmployeeContacts" EntityType="AdventureWorksModel.EmployeeContact" /&gt;
            &lt;/EntityContainer&gt;
          &lt;EntityType Name="EmployeeContact"&gt;
            &lt;Key&gt;
              &lt;PropertyRef Name="ContactID" /&gt;            
            &lt;/Key&gt;
            &lt;Property Name="EmployeeID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" /&gt;
            &lt;Property Name="NationalIDNumber" Type="String" Nullable="false" MaxLength="15" Unicode="true" FixedLength="false" /&gt;
            &lt;Property Name="LoginID" Type="String" Nullable="false" MaxLength="256" Unicode="true" FixedLength="false" /&gt;
            &lt;Property Name="Title" Type="String" Nullable="false" MaxLength="50" Unicode="true" FixedLength="false" /&gt;
            &lt;Property Name="BirthDate" Type="DateTime" Nullable="false" /&gt;
            &lt;Property Name="MaritalStatus" Type="String" Nullable="false" MaxLength="1" Unicode="true" FixedLength="true" /&gt;
            &lt;Property Name="Gender" Type="String" Nullable="false" MaxLength="1" Unicode="true" FixedLength="true" /&gt;
            &lt;Property Name="HireDate" Type="DateTime" Nullable="false" /&gt;
            &lt;Property Name="SalariedFlag" Type="Boolean" Nullable="false" /&gt;
            &lt;Property Name="VacationHours" Type="Int16" Nullable="false" /&gt;
            &lt;Property Name="SickLeaveHours" Type="Int16" Nullable="false" /&gt;
            &lt;Property Name="CurrentFlag" Type="Boolean" Nullable="false" /&gt;
            &lt;Property Name="rowguid" Type="Guid" Nullable="false" /&gt;
            &lt;Property Name="ModifiedDate" Type="DateTime" Nullable="false" /&gt;
            &lt;Property Type="String" Name="FirstName" Nullable="false" MaxLength="50" FixedLength="false" Unicode="true" /&gt;
            &lt;Property Type="String" Name="MiddleName" MaxLength="50" FixedLength="false" Unicode="true" /&gt;
            &lt;Property Type="String" Name="LastName" Nullable="false" MaxLength="50" FixedLength="false" Unicode="true" /&gt;
            &lt;Property Type="Int32" Name="ContactID" Nullable="false" annotation:StoreGeneratedPattern="Identity" /&gt;
          &lt;/EntityType&gt;
        &lt;/Schema&gt;
      &lt;/edmx:ConceptualModels&gt;
      &lt;!-- C-S mapping content --&gt;
      &lt;edmx:Mappings&gt;
        &lt;Mapping Space="C-S" xmlns="urn:schemas-microsoft-com:windows:storage:mapping:CS"&gt;
          &lt;EntityContainerMapping StorageEntityContainer="AdventureWorksModelStoreContainer" CdmEntityContainer="AdventureWorksEntities"&gt;
            &lt;EntitySetMapping Name="EmployeeContacts"&gt;            
              &lt;EntityTypeMapping TypeName="IsTypeOf(AdventureWorksModel.EmployeeContact)"&gt;              
                &lt;MappingFragment StoreEntitySet="Employee"&gt;
                  &lt;Condition ColumnName="ContactID" IsNull="false"/&gt;                
                  &lt;ScalarProperty Name="ContactID" ColumnName="ContactID"/&gt;
                  &lt;/MappingFragment&gt;
                &lt;MappingFragment StoreEntitySet="Contact"&gt;
                  &lt;ScalarProperty Name="ContactID" ColumnName="ContactID"/&gt;
                  &lt;/MappingFragment&gt;
              &lt;/EntityTypeMapping&gt;
              &lt;/EntitySetMapping&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;Designer xmlns="http://schemas.microsoft.com/ado/2007/06/edmx"&gt;
      &lt;Connection&gt;
        &lt;DesignerInfoPropertySet&gt;
          &lt;DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" /&gt;
        &lt;/DesignerInfoPropertySet&gt;
      &lt;/Connection&gt;
      &lt;Options&gt;
        &lt;DesignerInfoPropertySet&gt;
          &lt;DesignerProperty Name="ValidateOnBuild" Value="true" /&gt;
          &lt;DesignerProperty Name="EnablePluralization" Value="True" /&gt;
          &lt;DesignerProperty Name="IncludeForeignKeysInModel" Value="False" /&gt;
        &lt;/DesignerInfoPropertySet&gt;
      &lt;/Options&gt;
      &lt;!-- Diagram content (shape and connector positions) --&gt;
      &lt;Diagrams&gt;
        &lt;Diagram Name="Model1" ZoomLevel="70"&gt;
          &lt;EntityTypeShape EntityType="AdventureWorksModel.EmployeeContact" Width="1.5" PointX="3.25" PointY="0.5" Height="4.480205078125" IsExpanded="true" /&gt;
          &lt;/Diagram&gt;&lt;/Diagrams&gt;
    &lt;/Designer&gt;
  &lt;/edmx:Edmx&gt;
  </code></pre>