EF 6.0 - Map complex type to same table as parent property

ef-fluent-api entity-framework-6


I have looked at the following:

Entity framework code first map multiple complex types of the same type to a table

Given the example code:

[Table("TXLifeRequest", Schema = "txlife")]
public partial class TXLifeRequest
    public virtual OLI_LU_BOOLEAN PendingResponseOK { get; set; }

[Table("OLI_LU_BOOLEAN", Schema = "txlife")]
public partial class OLI_LU_BOOLEAN {

    public string tc { get; set; }

    public string Value { get; set; }

I would like to structure the database so that the OLI_LU_BOOLEAN is not in a new table, rather to be two new columns in the TXLifeRequest table as something like TXLifeRequest.PendingResponseOK_tc and PendingResponseOK _Value.

There is no fluent code in the existing context. Is there a way to do this either by fluent or attrubutes so that the class structure is intact but the tables are combined?


I have tried the following but it creates a new table TXLifeRequest1 for all of the OLI_LU_BOOLEAN properties. How would I specify these as properties of same table?


            c => new
                    Id = c.Int(nullable: false, identity: true),
                    PendingResponseOK_Value = c.String(),
                    PendingResponseOK_Id = c.Int(nullable: false)

9/7/2018 4:23:24 PM

Accepted Answer

The solution is to create a complex type:

modelBuilder.ComplexType<OLI_LU_BOOLEAN>().Ignore(i => i.Value);
9/10/2018 9:06:57 PM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow