c# - Toggle EF5 Connections During Runtime -


i've got project in ui have radio button list consists of 2 elements: development , production. in project i'm using ef5 model sprocs accomplish database ops. want create way use radio buttons toggle between development , production database servers during runtime cannot find way of doing this. need replace database server portion in connection string located in app.config. using transforms not appear option here.

is there way can accomplish without having reconstruct ef connectionstring?

you use dependency injection , have 2 dbcontext classes. based on radio button value, can determine dbcontext use.

or in dbcontext constructor, pass in connection string use:

public class mydbcontext : dbcontext {     public mydbcontext(string connstringname) : base("name=" + connstringname) { } } 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -