Confused regarding EntitySet requirements

Topics: ASP.NET Web API
Apr 9, 2014 at 3:21 AM
Hi, I'm moving my server from WCF Data Services with OData V1 (!) to WebApi2. There has been a bit to get my head around but I'm now at a point where I've exposed one of my entity sets for query and have it functioning. The key hurdle I had to overcome was the ODataConventionModelBuilder in WebApiConfig.Register. On calling config.Routes.MapODataRoute I was getting repeated exceptions which appeared to be a result of the 'builder' traversing my navigation properties and finding new entity types. I can understand this given the capability to $expand (which I intend on leaning quite heavily on), however nearly every single entity in my EDM is linked so I basically have to register every single entity type.

The main problem is when I look at my $metadata for the route it shows the DefaultContainer as having exposed EntitySets for every entityset I had to 'register' with the builder, but I've only implemented one of the entitysets. A result of this is that, should someone request my metadata and then attempt to request one of the 98% of entitysets that I HAVEN'T implemented, they get a 404 error!

I'm hoping that someone can answer the following question (or hopefully add a feature request for up-coming versions to resolve the problem I faced):
Why can I not simply supply the builder with a copy of my DBContext and then register only the entity sets that I have implemented?

Surely whatever process in the builder that detects an 'unexpected' entity type could then go to the DBContext and resolve the EntityType, without necessarily having to expose its equivalent EntitySet in the metadata??