Using a separate file to maintain the connection string for entity framework

僤鯓⒐⒋嵵緔 提交于 2019-11-29 07:16:24
Mortalus

I found the answer here Separate ConnectionStrings and mailSettings from web.config? Possible?:

<configuration>
    <connectionStrings configSource="connections.config"/> 
</configuration>

With file connections.config containing

<connectionStrings>
   <add name="name" connectionString="conn_string" providerName="System.Data.SqlClient" />
   <add name="name2" connectionString="conn_string2" providerName="System.Data.SqlClient" />
</connectionStrings>

In case anyone stumbles upon this question. You can put the connection strings in a separate config file using configSource but DONT expect the EF designer to work happily with it.

Every time to go to edit the edmx and 'Update from Database' it will ask for a new connection string and then always want to save it back to the web.config. Not ideal and for me not workable. This is the case in EF6 and previous.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!