Entity returned from stored procedue cannot contain complex type.


For the following POCOs

public class Graph
public Id {get; set;}
public Element prop{get; set;}

public class Element
public Id {get; set;}

where Graph is configured as EntityTypeConfiguration<Graph> and Element is configured as ComplexTypeConfiguration<Element>, a fault (InvalidOperationException) is thrown if a stored procedure invocation attempts to return ObjectResult<Graph>. If the graph is flattened, then the result can be processed.

System.Data.Entity.Core.Query.InternalTrees.ColumnMapFactory.GetColumnMapsForType() throws the error because it encounters a non-scalar type (Element) in Graph. However, Helpers.IsComplexType() could be used to detect complex type properties and extend the column graph appropriately, producing the same logical column map as the flattened object. For large entities returned from stored procedures this can be very useful organizationally.
Closed Nov 10, 2014 at 5:44 PM by RoMiller
Team Triage: This is a limitation of EF and not something that we are planning to add support for. The main reason we won't be adding support is that it would be complex to do given the metadata model in EF6.x and there are other higher priority items for us to address.

We would consider accepting a pull request on this feature if someone wanted to contribute it to EF6.x. We'll likely address this limitation in EF7 when we get to stored procedure support.


RoMiller wrote Nov 4, 2014 at 6:04 PM

Notes for triage: Confirmed that this is not supported anywhere in the stack. Even function imports in the designer explicitly block it in the UI.