0

我正在尝试为遗留项目设置持续集成。在 Web.config 中,有实体框架连接字符串:

<add name="StuffContext" 
     connectionString="
       metadata=res://*/Stuff.csdl|res://*/Stuff.ssdl|res://*/Stuff.msl;
       provider=System.Data.SqlClient;
       provider connection string=&quot;
         data source=mydbserver;
         initial catalog=mydb;
         persist security info=True;
         user id=loki2302;
         password=qwerty;
         multipleactiveresultsets=True;
         App=EntityFramework&quot;" 
       providerName="System.Data.EntityClient" />

有没有办法以某种方式提取provider connection string并在StuffContext连接字符串中按名称引用它?试图实现这样的目标:

...
<add name="StuffContext" 
     connectionString="metadata=...;name=StuffDb" />

<add name="StuffDb"
     connectionString="
       data source=mydbserver;
       initial catalog=mydb;
       persist security info=True;
       user id=loki2302;
       password=qwerty;
       multipleactiveresultsets=True;
       App=EntityFramework" />
...
4

1 回答 1

0

不在web.config,不,但您当然可以使用EntityConnectionStringBuilder来完成。

于 2013-05-14T12:22:58.620 回答