Friday, September 30, 2011

Quick Post: Make sure your EF Entities are related

I am debugging a problem with one of my projects products.  It is a WCF service based on Microsoft ADO.NET Data Services, and uses Entity Framework.

A bug reported some anomalies when querying a specific custom method, which returns a filtered list of people based on input parameters.  Each parameter named an entity, a filter value, and the logical operator for that filter.  For each parameter, the custom method would traverse the entity model until it determined how that entity was related to the central Person entity.  It would then perform the filter.  Not a perfect implementation, but fine to implement.

Unless...

That entity does not have any defined relationships with the central Person entity. 

Moral of the story:  Make sure your entity model is proper!

No comments:

Post a Comment