I have a baseball statistics database that contains composite primary and foreign keys throughout the schema. Here is an example and partial schema from the database:

clip_image001

I am trying to build a RIA Services application that shows views of the data from this portion of the database schema and a few other angles from the database. I am running into a few issues involving from the composite keys in the tables associated with the Player table.

First Entity Framework 4 does not create all of the Associations in the EDM and gives numerous warnings

The relationship ‘FK_Batting_Teams’ uses the set of foreign keys ‘{yearID, lgID, teamID}’ that are partially contained in the set of primary keys ‘{playerID, yearID, stint}’ of the table ‘Batting’.  The set of foreign keys must be fully contained in the set of primary keys, or fully not contained in the set of primary keys to be mapped to a model.                c:userscwoodruffdocumentsvisual studio 2010ProjectsBusinessApplication1BusinessApplication1.WebModel.edmx

These warnings can be resolved by removing the warnings from the EDM and creating the Associations by hand (that was an earlier email and thanks to Danny Simmons).

I added the following to the metadata on the server side. You show the composite key in the association through the Association annotation.

I also added the following changes to the DomainService get method regarding the Player Entities for the required loading of the associated entity data.

With no change to the client side. I still am not getting any associated data when looking at the WCF Binary via Fiddler. I am just curious if the client side needs to reflect this same Association in the generated code?

Looking at the generated code in the Silverlight project you will see the following method on the client side for the Player Entity class. My question is about the Association annotation. Should the generated Association not also include the entire composite key from the Entity Framework Entity Data Model?

So this is my issue I have been asking others inside and out the RIA Services product team. I am interested in what the solution is and if it is a bug in the WCF RIA Services product will ir be fixed soon?

2 thoughts on “The WCF RIA Services Issue I am trying to solve currently: Entity Framework 4 with Composite Associations

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.