O'Reilly Forums: Chapter 14 Mapping Tpt Inheritiance Steps Do Not Match What I Am Seeing - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Chapter 14 Mapping Tpt Inheritiance Steps Do Not Match What I Am Seeing

#1 User is offline   WhiskeyRomeoLima 

  • Active Member
  • PipPip
  • Group: Members
  • Posts: 30
  • Joined: 29-October 11

Posted 19 November 2011 - 08:21 AM

After the topic heading Mapping TPT Inheritance (p362 of Kindle version), step 8 says:

"Map the Customer’s new ContactID property (which now comes from the Contact entity) to the ContactID column in the Customers table."

I right click on Customer in the model design view, click on Table Mappings, and I see mappings but no opportunity to map from the Contact.ContactID to Customer.ContactID. I do see the arrow glyph on Customer table. Is this handled automatically when creating the Inhertance under VS 2010 now? <_<
0

#2 User is offline   JulieLerman 

  • Advanced Member
  • PipPipPipPipPipPipPipPip
  • Group: O'Reilly Author
  • Posts: 334
  • Joined: 17-September 08

Posted 19 November 2011 - 08:58 AM

not sure what the problem is. Just opened up the model in vs2010 (sp1) and took this screenshot for you:

http://screencast.com/t/ioNEDVLj

I ensured that I was using the version of the model where customer is inheriting from contact.
0

#3 User is offline   WhiskeyRomeoLima 

  • Active Member
  • PipPip
  • Group: Members
  • Posts: 30
  • Joined: 29-October 11

Posted 19 November 2011 - 12:56 PM

I was not exactly clear: (I had too much tequila last night. Jose Cuervo, you are friend of mine . . .)

Once I completed step 6, steps 7,8 were already done. So I was confused about whether or not EF already figuered out the mapping.

I will have to reset the model and look at the model before and after doing step 4.

Again, thank you for your time.
0

#4 User is offline   JulieLerman 

  • Advanced Member
  • PipPipPipPipPipPipPipPip
  • Group: O'Reilly Author
  • Posts: 334
  • Joined: 17-September 08

Posted 19 November 2011 - 01:06 PM

wait...so you are reading the book and writing code in between tequila shots and wonder why things are a little blurry? (don't worry I'm laughing)
0

#5 User is offline   WhiskeyRomeoLima 

  • Active Member
  • PipPip
  • Group: Members
  • Posts: 30
  • Joined: 29-October 11

Posted 20 November 2011 - 11:02 AM

Your screen print matches exactly what I got when I repeated those steps. However, when I did Step 7, the mapping was already in place. I did not have to physically perform Step 8.

Since table mappings show the mapping between the store and conceptual model, I don't see how one can determine how the ContactID on Customer comes from Contact.ContactID by looking at that dropdown.

I will poke around in the XML to see what changed. But right now I am confused and I think this is an important concept to have clear in one's mind before going forward. :blink:
0

#6 User is offline   WhiskeyRomeoLima 

  • Active Member
  • PipPip
  • Group: Members
  • Posts: 30
  • Joined: 29-October 11

Posted 20 November 2011 - 11:38 AM

[size="5"][/size]Here is what I found by looking at the XML of the Model as result of the changes referred in previous post.

In CSDL Section there is no:

- Entity Set for Customer
- Association Set for Customer & Contact

But there is this mapping:

<EntitySetMapping Name="Contacts">
<EntityTypeMapping TypeName="IsTypeOf(BAModel.Contact)">
<MappingFragment StoreEntitySet="Contact">
<ScalarProperty Name="ContactID" ColumnName="ContactID" />
<ScalarProperty Name="FirstName" ColumnName="FirstName" />
<ScalarProperty Name="LastName" ColumnName="LastName" />
<ScalarProperty Name="Title" ColumnName="Title" />
<ScalarProperty Name="AddDate" ColumnName="AddDate" />
<ScalarProperty Name="ModifiedDate" ColumnName="ModifiedDate" />
<ScalarProperty Name="RowVersion" ColumnName="RowVersion" />
</MappingFragment>
</EntityTypeMapping>
<EntityTypeMapping TypeName="IsTypeOf(BAModel.Customer)">
<MappingFragment StoreEntitySet="Customers">
<ScalarProperty Name="CustomerRowVersion" ColumnName="RowVersion" />
<ScalarProperty Name="ContactID" ColumnName="ContactID" />
<ScalarProperty Name="CustomerTypeID" ColumnName="CustomerTypeID" />
<ScalarProperty Name="InitialDate" ColumnName="InitialDate" />
<ScalarProperty Name="PrimaryDesintation" ColumnName="PrimaryDesintation" />
<ScalarProperty Name="SecondaryDestination" ColumnName="SecondaryDestination" />
<ScalarProperty Name="PrimaryActivity" ColumnName="PrimaryActivity" />
<ScalarProperty Name="SecondaryActivity" ColumnName="SecondaryActivity" />
<ScalarProperty Name="Notes" ColumnName="Notes" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>

This post has been edited by WhiskeyRomeoLima: 20 November 2011 - 11:45 AM

0

#7 User is offline   JulieLerman 

  • Advanced Member
  • PipPipPipPipPipPipPipPip
  • Group: O'Reilly Author
  • Posts: 334
  • Joined: 17-September 08

Posted 20 November 2011 - 11:43 AM

that's correct. Since customer inherits from contact, it depends on the contacts entityset now. I would NOT worry about the fact that the designer handled mapping the ID for you. Move on... As long as you understand that Customer inherits the ContactID from the Contact entity and that ContactID maps to the primary key of the customer table in the database...your good.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users