To get this string compilation ...
Property(p => p.Age).HasColumnName("AGE").IsOptional();
... you need to make the Age property nullable:
public Nullable<Int32> Age { get; set; }
(or public int? Age { get; set; } )
Or you cannot specify a property as optional and use it as a necessary property.
Edit
My answer above is wrong. This is not the cause of the compiler error. But the Age property should still be NULL if it should be optional, i.e. Allow null values.
Edit 2
In your model, MTObject is a complex type (not an entity) because, by convention, EF cannot derive a primary key property. For a complex type, you can map nested properties as:
Property(p => p.Name.Object).HasColumnName("NAME");
(assuming you really want to specify the column name for the Object property). Using IsOptional() not required since string properties are optional by default.
source share