Currently for an IEdmModel to be used with the ODataMediaTypeFormatters, it MUST be built using an ODataModelBuilder. This is because the formatters require an annotation on IEdmEntitySet using a class called EntitySetLinkBuilderAnnotation, and this class is internal.
However there are clearly scenarios where people want to create there own IEdmModel. For example from:
- DbContext
- IDataServiceMetadataProvider
I see a layered solution.
First make EntitySetLinkBuilderAnnotation public, and give it a constructor that doesn't require an EntitySetConfiguration (you don't necessarily have one of those).
Second make the Formatter annotate the model if an EntitySetLinkBuilderAnnotation is not found, this way if a service follows conventions (most do) then you don't need to annotate the IEdmModel you build at all.
I have attached a patch file showing a fix for the first part.
However there are clearly scenarios where people want to create there own IEdmModel. For example from:
- DbContext
- IDataServiceMetadataProvider
I see a layered solution.
First make EntitySetLinkBuilderAnnotation public, and give it a constructor that doesn't require an EntitySetConfiguration (you don't necessarily have one of those).
Second make the Formatter annotate the model if an EntitySetLinkBuilderAnnotation is not found, this way if a service follows conventions (most do) then you don't need to annotate the IEdmModel you build at all.
I have attached a patch file showing a fix for the first part.