c# - Switching EF connection strings at runtime -
i know question has been asked , answered few times already, every answer have encountered has either been incomplete, overly vague or assumes more prerequisite knowledge have. seeking step-by-step instructions, in reasonably plain english, swap out database in default connection string database name looked in table. keep coming across snippet of code...
public dfdbentities(string connectionstring) : base(connectionstring) { }
...but no 1 explains how, , where, implement it. assuming have class called "db" represents datamodel.edmx model...
private datamodel db = new datamodel();
...how change connection string associated class point different physical database (with identical data structure)?
by using default constructor saying "i want use default connection string" specified in web.config
.
the dbcontext
has constructor overload allows override default connection string, need pass in
db = new datamodel("myconnectionstr");
Comments
Post a Comment