Wait! which config file? (Entity Framework Connection String)

╄→尐↘猪︶ㄣ 提交于 2019-11-30 03:16:43

We ran into the same situation. I've asked each developer to only ever compile the EF assembly with the first connection string selected.

This way, when deployed, only one connection string is needed in the web.config.

Eventually, if each development machine and deployment server has the correct connection information (for that machine) in the first (and hopefully only) connection string (i.e., not ConnectionString4), life is easy.

Basically, extra connection strings are added by the designer to the dev connection string when the default connection string (latest selected) can't connect.

Also, there's no reason to feel bad about putting the data layer into a separate assembly. Sometimes this is preferable.

Finally, it's pretty important to make sure the config file that contains the connection string is not hooked to source control -- the connection string is often localized and will cause the "multi-connection-string-issue" in EF and LINQ to SQL if it keeps getting overwritten with bad values every time you update your project from source control.

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