Visual studio created a unit test project for me based on a method (right-click add test). When I try to access the database, I get an exception. Ran this code to see what my connection was:
ConnectionStringSettings connStringSettings = ConfigurationManager.
ConnectionStrings["myConnectionString"];
but, connStringSettings
is null. Upon inspection, ConnectionStrings collection has a count of only one. It seems to not be reading from my web.config.
My DAL is isolated and cannot have its connection string set through code. Its connection string is set in code like this:
set
{
value = System.Configuration.ConfigurationManager.
ConnectionStrings["myConnectionString"].ConnectionString;
}
How can I resolve this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…