c# - Set database schema name without setting table name -
i want set database schema name table, way using method totable:
modelbuilder.entity<myentity>().totable("mytable", schemaname); however don't want set table name explicitly, need this:
modelbuilder.entity<myentity>().toschema(schemaname); can me it?
using extension method:
using system.data.entity.modelconfiguration; public static class modelconfigurationhelper { public static entitytypeconfiguration<t> toschema<t>(this entitytypeconfiguration<t> config, string schema) { return config.totable(typeof(t).name, schema); } } you can do:
protected override void onmodelcreating(dbmodelbuilder modelbuilder) { modelbuilder.entity<myentity>().toschema("someschema); }
Comments
Post a Comment