What is the equivalent to AssociationType in Entity Framework Core 2? -


i use convention (istoremodelconvention) need know if associationtype.isforeignkey true. objective rename foreign keys in mapped tables. example, remove underscore , compose totally new name derived classes , properties names.

the question is: exists equivalent associationtype.isforeignkey in entity framework core 2 or how can accomplish type of customization?

ef core 2 has different (or better) naming system foreignkeys. name constructed fk_table_referencedtable_fkproperties table fk constraint defined. referencedtable principal side. , fkproperties _ separated list of foreign key properties. perhaps match naming system want.

though if want still customize names of foreign key properties, in ef core there no user defined convention support yet. ef core allows iterate on model metadata configure way want. in onmodelcreating method in derived dbcontext can put following code name fk want.

protected override void onmodelcreating(modelbuilder modelbuilder) {     // configure model     foreach (var entitytype in modelbuilder.model.getentitytypes())     {         foreach (var declaredforeignkey in entitytype.getdeclaredforeignkeys())         {             declaredforeignkey.relational().name = "<construct_fk_name>";         }     } } 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -