Code: Select all
    public class Thing
    {
        public Thing()
        {
            DV = "A";
        }
        public string Id { set; get; }
        public string Property1 { set; get; }
        public string DV { set; get; }
    }
    public class AThing : Thing
    {
        public AThing():base()
        {
            DV = "A";
        }
        public string P2 { set; get; }
    }
Code: Select all
       builder.Entity<Thing>()
            .FullTableName("THING_TABLE")
            .PrimaryKey(p => p.Id);
        // Table Per Hierarchy (TPH) inheritance:
        builder.Entity<Thing>()
            .Map().Discriminator(p => p.DV)
            .DiscriminatorValue("R")
            .IsInheritanceDefault()
            .MapChild<AThing>()
            .DiscriminatorValue("A")
            ;
        // Properties:
        builder.Entity<Thing>()
            .Property(p => p.Id)
            .ServerDataType("varchar(40)")
            .ColumnName("Id");
        builder.Entity<Thing>()
            .Property(p => p.Property1)
            .ServerDataType("varchar(40)")
                .ColumnName("Property1");
        builder.Entity<Thing>()
            .Property(p => p.DV)
            .ServerDataType("varchar(1)")
            .ColumnName("Dv");
        builder.Entity<AThing>().Property(p => p.P2).ColumnName("P2");
If I insert an AThing, *only* the P2 column is set, all other rows are unset (default value or null).
The log console clearly shows that only the derived properties are being set
Code: Select all
INSERT INTO THING_TABLE (P2) VALUES (:p1)
-- p1: Input VarChar (Size = 10; DbType = AnsiString) [some stuff]
Thanks