Connection string hell in .NET / LINQ-SQL / ASP.NET

后端 未结 13 1126
渐次进展
渐次进展 2021-01-30 14:29

I have a web application that comprises the following:

  • A web project (with a web.config file containing a connection string - but no data access code in the web pr
13条回答
  •  鱼传尺愫
    2021-01-30 14:42

    Here's one way to look at it. Which component should make the decision about which database to use? It's possible that the database (or at least the connection string) could change in the future. Does the website decide which database to use? Or, does the DAL decide?

    If you have dev, QA, UAT and prod databases, managing these connection strings is crucial.

    If the website decides, it should pass the connection string from its web.config to the DAL. If the website isn't supposed to know or care where the data comes from, then the connection string belongs in the DAL.

提交回复
热议问题