//实体类
[table("invoiceinfo", schema = "obs")] public class invoice { [key] public string invoice_num { get; set; } public string merchant_id { get; set; } public datetimeoffset? verify_time { get; set; } //one to many
public virtual ilist<invoice_relation> invoice_file_list { get; set; }   //one to one public virtual business invoice_business { get; set; } }
//数据库  postgredbcontext相关配置

protected override void onmodelcreating(modelbuilder builder) { base.onmodelcreating(builder); builder.entity<invoice>().hasmany(i => i.invoice_file_list).withone().hasforeignkey(f => f.invoice_num); builder.entity<invoice>().hasone(i => i.invoice_business).withmany().hasforeignkey(i => i.merchant_id); }
 //.file为invoice_file_list类中字段属性,.invoiced_party为invoice_business字段属性
iqueryable<invoice> invoicelist = _postgredbcontext.invoice.asnotracking().include("invoice_file_list.file").include("invoice_business.invoiced_party");