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

Popular posts from this blog

java - HTTP Status 500 - An exception occurred processing JSP page /second.jsp at line 15 -

php - Using str_replace to translate a MySQL Table in html -

SQL Server - MyCTE query based on 24 hour period (next day) -