简体   繁体   中英

Connection string with ASP.Net

I have a solution with three projects:

  1. A web application (WA)
  2. A Data Model Layer (DML) using code first, and
  3. A Data Access Layer (DAL)

The WA's web.config and the DML's app.config each have a connection string section specifying a connection string for the database.

I've noticed that the DML connection string doesn't really matter. So is it safe to completely remove this section from the app.config file?

Also, why is this string unused? Finally, I'm guessing when the application is run, the connection to the database is established using the connection string in the web.config file and the database definition is managed by the DML/DAL?

Is this because the other projects aren't really being run per se, just the methods and properties are being referenced? Thanks

Yes, you can remove connection string from DML's app.config. It is unused because you are starting the web application and only it's config does matter at runtime.

Everything needs to go into your app.config / web.config. The config files on the library project only help you to keep track of things that need to go into your app.config

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM