Question

I am currently working on an OData Web API 2 service using EF6 with a code first approach.

The breeze documentation suggests the use of the EdmBuilder over the ODataConventionModelBuilder for multiple reasons (http://www.breezejs.com/documentation/odata-server). I had a couple of questions over this-:

1) The ODataConventionModelBuilder appears to not generate the 'ReferentialConstraint' tag thereby having an impact on $select after $expand on using the breeze js client. But strangely, the same appears to work when directly typed into the browser (using $expand & $select), Is there any work around to using the ODataConventionModelBuilder? Are all the issues stated in the link still applicable?

2) We opted for a pure OData service to make our API accessible for varied OData consumers, we wish to keep our services generic without any breeze flavor to it. Will the addition of the EdmBuilder make the service breeze specific?

Was it helpful?

Solution

As you discovered Microsoft's ODataConventionModelBuilder does NOT provide referential constraints. So far, using the EdmBuilder is the only workaround. Using the EdmBuilder does not make the service breeze specific, because there is no breeze specific code there. (The code for EdmBuilder was actually provided by a Microsoft engineer.) However, using the EdmBuilder does preclude you from using the rest of the ODataConventionModelBuilder functionality, which is annoying.

What we are considering, is allowing the OData metadata delivered from the server to be modified/updated via series of api calls where you would declare the relational constraints directly on the client. You would then be using the ODataConventionModel builder instead of the EdmBuilder and using the 'new' api to 'reset' the constraints. This is obviously not as good as retrieving the data from the server, but until MS fixes the ODataConventionModelBuilder this may be our best bet.

Would this be of value in your scenario?

Also, please contact MS and let them know of your frustration. :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top