I am using a T4 template slightly modified from the one proposed in this answer to generate typescript interfaces from my EF POCOs.
The EF Core POCOs were generated database first, and some of the database columns have default values. These are correctly mapped by the EF generator into my context, e.g. .HasDefaultValueSql("0")
;
I'm a little confused about how to go about accessing the default value for a given EF class, i had thought GetValueOrDefault
might do the trick but that's just giving the default value for the .net type.
I see there are some other solutions out there for getting this working but i can't seem to find one that yet works with ASP .Net Core.
Ideally, i would like to know how to determine if a property has a default EF value from it's MemberInfo, as the following line from the T4 template is generating the property descriptions it would be the easiest to modify that to output a default value for the TypeScript def.
foreach (MemberInfo mi in GetInterfaceMembers(t))
{
sb.AppendFormat(" {0}: {1};\n", mi.Name, GetTypeName(mi));
}