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

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -