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.
Comments: I'm currently working with a database that unfortunately didn't follow any standard naming conventions as well as missing a lot of foreign keys, etc. I've cleaned up my model quite a bit, so I have EntitySetConfiguration's that were created with customized T4 templates. Would this change you're proposing allow me to use these if needed?
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.
Comments: I'm currently working with a database that unfortunately didn't follow any standard naming conventions as well as missing a lot of foreign keys, etc. I've cleaned up my model quite a bit, so I have EntitySetConfiguration's that were created with customized T4 templates. Would this change you're proposing allow me to use these if needed?