1

I have the following model:

public class TranscoderConfiguration {

    public int                Id                    { get; set; }
    public NetworkEndpoint    SourceEndpoint        { get; set; }
    public NetworkEndpoint    DestinationEndpoint   { get; set; }

}

public class NetworkEndpoint {

    public byte[] Address { get; set; }
    public int    Port    { get; set; }

}

Now EF tries to map the code first model this way:

    Id    |    Address    |    Port    |    Address    |    Port
---------------------------------------------------------------------

Which obviously doesn't work. How can I define that EF should map complex types prefixed by their property name? Such as SourceEndpoint.Address etc?

Acrotygma
  • 2,531
  • 3
  • 27
  • 54
  • I am surprised that this works at all. You haven't defined a key in `NetworkEndpoint` and you should be getting "EntityType 'NetworkEndpoint' has no key defined. Define the key for this EntityType" when you add a migration. Have you missed something out? – Colin Jan 14 '14 at 15:40
  • I have no idea how it worked, but you may want to add `[ComplexType]` Attribute to `NetworkEndpoint`. – Matan Shahar Jan 14 '14 at 16:50
  • https://stackoverflow.com/questions/40674883/add-column-name-convention-to-ef6-fluentapi – brijber Jun 22 '18 at 08:07

0 Answers0