Note that there are some explanatory texts on larger screens.

plurals
  1. POEntity Framework - Entity Mapping problem
    primarykey
    data
    text
    <p>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.</p> <p>I do want to create a new entity that contains information from both entities.</p> <p>What I did so far:</p> <p>In CSDL:</p> <pre><code>&lt;EntityContainer...&gt; &lt;EntitySet Name="AddressTest" EntityType="WebGearsModel.Test" /&gt; &lt;EntitySet Name="ContactTest" EntityType="WebGearsModel.Test" /&gt; &lt;/EntityContainer&gt; &lt;EntityType Name="Test"&gt; &lt;Key&gt; &lt;PropertyRef Name="addressID" /&gt; &lt;/Key&gt; &lt;Property Type="Int32" Name="addressID" Nullable="false" annotation:StoreGeneratedPattern="Identity" /&gt; &lt;Property Type="Int32" Name="contactID" Nullable="false" /&gt; &lt;Property Type="String" Name="firstName" Nullable="false" MaxLength="30" FixedLength="false" Unicode="false" /&gt; &lt;Property Type="String" Name="emailAddress" Nullable="false" MaxLength="150" FixedLength="false" Unicode="false" /&gt; &lt;/EntityType&gt; </code></pre> <p>In my C-S mapping:</p> <pre><code>&lt;EntitySetMapping Name="AddressTest"&gt; &lt;EntityTypeMapping TypeName="WebGearsModel.Test"&gt; &lt;MappingFragment StoreEntitySet="Address"&gt; &lt;ScalarProperty Name="addressID" ColumnName="addressID" /&gt; &lt;ScalarProperty Name="contactID" ColumnName="contactID" /&gt; &lt;ScalarProperty Name="firstName" ColumnName="firstName" /&gt; &lt;/MappingFragment&gt; &lt;/EntityTypeMapping&gt; &lt;/EntitySetMapping&gt; &lt;EntitySetMapping Name="ContactTest"&gt; &lt;EntityTypeMapping TypeName="WebGearsModel.Test"&gt; &lt;MappingFragment StoreEntitySet="Contact"&gt; &lt;ScalarProperty Name="contactID" ColumnName="contactID" /&gt; &lt;ScalarProperty Name="emailAddress" ColumnName="emailAddress" /&gt; &lt;/MappingFragment&gt; &lt;/EntityTypeMapping&gt; &lt;/EntitySetMapping&gt; </code></pre> <p>The error I'm receiving is:</p> <blockquote> <p>Problem in mapping fragments starting at line 150:Must specify mapping for all key properties (ContactTest.addressID) of the EntitySet ContactTest.</p> </blockquote> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload