Should the connectionstring come from the mvc project or the data project?

荒凉一梦 提交于 2019-12-24 12:16:31

问题


When using a separate project to handle db operations in an mvc project, should I store the connectionstring in the dbproject (using app.config) or should I keep the connectionstring in the web.config of the mvc project, and inject it into the repository (provided by the dbproject) when instantiating it?


回答1:


The config is always read from the outermost app. The web.config is where your connectionstring should be.

You can read it from your db project just as if it were the main project. You don't need to inject or do anything special.



来源:https://stackoverflow.com/questions/5894153/should-the-connectionstring-come-from-the-mvc-project-or-the-data-project

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