Closed samunro closed 8 years ago
Thank you for bring up this issue. I spent quite some time to investigate, but I do not have a fix at this moment.
Entity Framework database first supports table valued function to return entity type. To make this work in code first, a proper API is needed to build an empty C-S mapping like this:
<FunctionImportMapping FunctionName="Model.Store.ufnGetCategoryProducts" FunctionImportName="ufnGetCategoryProducts">
</FunctionImportMapping>
Unfortunately, I was not able to find an EDM API to do that. I also read the source code of Entity Framework, got no luck. It seems using complex type is the only option for this scenario. Sorry for the inconvenience.
I have been getting the following error and I narrowed it down to returning an entity - as opposed to a complex type - from a table valued function.
If I return a complex type from the function instead of the entity then all works as expected. I was even able to take the class that was originally an entity, register it as a complex type (after removing the DbSet property on the context to prevent it from being registered as an entity) and that worked too.
Is there anything that I can do to be able to return an entity from a table valued function? Is this a feature that is planned? Any idea how far off it might be?
Many thanks,
Scott