问题
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