Using Defining Query To Create Your Own Views, Creating the Association on Page 376 |
![]() ![]() |
Using Defining Query To Create Your Own Views, Creating the Association on Page 376 |
Nov 4 2009, 05:07 PM
Post
#1
|
|
|
|
Hi Julie,
If you get a chance, ran into another bump: Creating an association between the new UnpaidReservation entity and the Reservation entity. I know you're extremely busy, so please disregard my previous post. I'm more concerned about this one, because you are keeping the DefiningQuery as a permanent addition to the model going forward. I'd really like to get it to run. All the code I'm using is straight out of the walk-through. Here's my problem: 1. UnpaidReservation has a Key of ReservationID. 2. Reservation has a Key of ReservationID. 3. The One to Many association - 'ReservationUnpaidReservation' - maps the Reservation entity's Key to the UnpaidReservation entity's Key. How is this possible? Shouldn't the Reservation entity have to map its Key to a FORIEGN KEY defined in the many-side entity (virtual table). But there is no foreign key defined in the many-side entity. What we end up with - as illustrated in the book - is the Store.UnpaidReservations.ReservationID property mapped to TWO other properties: both the BAModel.UnpaidReservation.ReservationID and the BAModel.Reservation.ReservationID. The Entity Framework doesn't like this. When I run the code in Example 13-9, page 377, I get: QUOTE error 3021: Problem in Mapping Fragment starting at line 354: Each of the following columns in table UnpaidReservations is mapped to multiple conceptual side properties: UnpaidReservations.ReservationID is mapped to ReservationUnpaidReservation.UnpaidReservation.ReservationID, ReservationUnpaidReservation.Reservation.ReservationID My AssociationSetMapping that is causing the problem: CODE <AssociationSetMapping Name="ReservationUnpaidReservation" TypeName="BAModel.ReservationUnpaidReservation" StoreEntitySet="UnpaidReservations"> <EndProperty Name="UnpaidReservation"> <ScalarProperty Name="ReservationID" ColumnName="ReservationID" /> </EndProperty> <EndProperty Name="Reservation"> <ScalarProperty Name="ReservationID" ColumnName="ReservationID" /> </EndProperty> </AssociationSetMapping> Thanks, Bob |
|
|
|
Nov 4 2009, 06:20 PM
Post
#2
|
|
|
|
QUOTE How is this possible? Shouldn't the Reservation entity have to map its Key to a FORIEGN KEY defined in the many-side entity (virtual table). But there is no foreign key defined in the many-side entity. Found the foreign key!!! You include it in your Chapter 14 version of the model. It just isn't included in the Chapter 13 walk-through. So if one runs Example 13-9 against the Chapter 14 model, all is well. Only glitch with the Chapter 14 model: The Activity entity doesn't have a Category scalar property (I don't know if you loose it in Chapter 14 yet or not). But to use the model for my chapter 13 purposes, I had to add the Category property to the Activity entity because the column Activities.Category in the SSDL table Activities must be mapped. So all is well, 'cept since I figured this one out, if you get a chance, I'd still be interested in your thoughts about my Native Query post. Glitches are good (and inevitable). Working them out forces one into the inner workings of this beast. Its taken me three weeks, but I'm getting it. Thanks, Bob |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 22nd November 2009 - 05:10 AM |