我添加了一个连接,它显示在“其他连接”中,但我似乎无法引用它。
var db = Database.Open("MyNewConnection");
抛出异常:Connection string 'MyNewConnection' was not found.
答案 0 :(得分:6)
您是否检查过以确保您的web.config文件中的连接字符串是否正确?
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add
name="MyNewConnection"
connectionString= "server=myServer;database=myDatabase;uid=username;pwd=password"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>