c# - EF getting mapped column name from string -
i have 3 entities share common base class. each of entities have own map class context , load fine. each entity has different primary key name rename in base class can use generic methods of the 3 entities while using same property name.
everything maps fine when going database, example can db.vehicle.where(v => v.vehicleid < 100)
, translates db column name different vehicleid
.
the problem wanting go opposite direction. example might have string "length"
in 1 table might length1
, in length2
. want use same mapping used in model builder able translate "length"
whatever corresponding value based on (v => v.length
) property in base class.
does have ideas on how might accomplished?
if have tried fluent api , did not work, recommend declaring property virtual.
modelbuilder.entity<concreteclass1>() .property(f => f.length) .hascolumnname("length1"); modelbuilder.entity<concreteclass2>() .property(f => f.length) .hascolumnname("length2");
Comments
Post a Comment