I have two tables: Address and Contact which are joined on contactID (in Contact). Both of these tables have entities in my Entity data model (EF 4.0) and I do not wan't to modify them.
I do want to create a new entity that contains information from both entities.
What I did so far:
In CSDL:
<EntityContainer...>
<EntitySet Name="AddressTest" EntityType="WebGearsModel.Test" />
<EntitySet Name="ContactTest" EntityType="WebGearsModel.Test" />
</EntityContainer>
<EntityType Name="Test">
<Key>
<PropertyRef Name="addressID" />
</Key>
<Property Type="Int32" Name="addressID" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Type="Int32" Name="contactID" Nullable="false" />
<Property Type="String" Name="firstName" Nullable="false" MaxLength="30" FixedLength="false" Unicode="false" />
<Property Type="String" Name="emailAddress" Nullable="false" MaxLength="150" FixedLength="false" Unicode="false" />
</EntityType>
In my C-S mapping:
<EntitySetMapping Name="AddressTest">
<EntityTypeMapping TypeName="WebGearsModel.Test">
<MappingFragment StoreEntitySet="Address">
<ScalarProperty Name="addressID" ColumnName="addressID" />
<ScalarProperty Name="contactID" ColumnName="contactID" />
<ScalarProperty Name="firstName" ColumnName="firstName" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="ContactTest">
<EntityTypeMapping TypeName="WebGearsModel.Test">
<MappingFragment StoreEntitySet="Contact">
<ScalarProperty Name="contactID" ColumnName="contactID" />
<ScalarProperty Name="emailAddress" ColumnName="emailAddress" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
The error I'm receiving is:
Problem in mapping fragments starting at line 150:Must specify mapping for all key properties (ContactTest.addressID) of the EntitySet ContactTest.
How am I supposed to map an AddressID from the Contact entity when it doesn't exist in that entity? I guess I need some sort of association but I'm unsure how to go about it... Remember, I don't want to have to modify my existing Address and Contact entities.