Entity framework nesting complex types


I have a stored procedure that returns multiple result sets. Each one is a complex type. The first result set would contain a list of items of the same complex type as the second result set, etc. These do not cleanly correlate to specific entities. For example, my POCO classes should be

public partial class Message
    public string Subject { get; set; }
    public List<Recipient> Recipients { get; set; }

public partial class Recipient
    public string Email { get; set; }

According to the documentation, "Entity and complex types can now be nested inside classes" for EF 6. However, I cannot figure out how to create a LIST of a complex type within my first complex type. When I edit my FunctionImport and use Get Column Information, it only returns the first complex type. When I try Create New Complex Type, it still only returns the first complex type. Finally, I have created all of the complex types I need manually and tried to add the Recipient complex type to the Message complex type, it will only allow a single Recipient to be added. Is there something special you need to do to nest complex types? Are there any examples out there? I could not find anything that addressed this on CodePlex, but I may just be missing it.

Thanks in advance for all your help!

Accepted Answer

By nesting is in my opinion meant putting one class declaration into another:

public class A {
    public class B { }

In previous versions of EF, class B could not be mapped neither as entity or complex type while in EF6 it can be. It is the only meaning of nesting related to this feature.

When it comes to your question you still cannot map list of complex types. If you want a list you need to use entities (both as parent and children).

Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why