Entity Framework core configurations -


in ef 6 directly pass entitytypeconfiguration model builder build maps , keep our configuration class separate context without being verbose in code.

have removed maps in ef core. there way add configuration without doing in model builder every class?

the best way keep configuration code away onmodelcreating method. can like:

create class store actual configuration:

public class applicationuserconfiguration {     public applicationuserconfiguration(entitytypebuilder<applicationuser> entity)     {         // here have stuff         entity.totable("user", "identity");          entity.property(p => p.id)             .hascolumnname("id);          // , on ....     } } 

and onmodelcreating instantiate new created class , pass correct entity:

protected override void onmodelcreating(modelbuilder builder) {     base.onmodelcreating(builder);      // custom configs here     new applicationuserconfiguration(builder.entity<applicationuser>()); } 

is clean , simple way achieve goal.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -