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 -

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

Why does a .NET 4.0 program produce a system.unauthorizedAccess error on a Windows Server 2012 machine with .NET 4.5 installed? -