0

I have a ASP.NET MVC 4 web project

WebUI

that references a ASP.NET 4 Code Library

DAL

The Code Library has a reference to the SlowCheetah 2.5.5 NuGet package and is setup with several transformations for it's App.Config.

The WebUI is using the normal Web.Config transformations but I have also added a reference to SlowCheetah as a test for my problem but it didn't change my issue.

When I publish using

MS Web Deploy

in Visual Studio 2012 or when I publish straight to

File System

using a QA configuration the correct Web.QA.config is put in the root of my website, however the referenced class library configuration is not working, I get a sql connection error on the home page which alerts me that the correct App.Config transformation is most likely not being used for the referenced DAL project.

I thought this would be a .dll.config file in the bin folder for the WebUI, but I am not too sure as I have this working on another web server where I manually changed the default App.Config and Web.Config files and there is no .dll.config file present in the root bin directory of the website.

Anyone know how to get this working?

UPDATE:

Examples below:

DAL Code Library project App.Config

<configuration>
    <configSections>
 </configSections>
    <connectionStrings>
  <add name="DAL.Properties.Settings.DefaultConnection" connectionString="Data Source=(local);Initial Catalog=MyDB;Integrated Security=True;" />
 </connectionStrings>
</configuration>

Part of Web.Config from my WebUI project

  <connectionStrings>
    <add name="WebUI.Properties.Settings.DefaultConnection" connectionString="Data Source=(local);Initial Catalog=MyDB;Integrated Security=True;" />
  </connectionStrings>

I use a Settings.settings file for each project.

How can I merge the App.Config connection into my Web.Config so that it is transformed during publishing? preferably I would want it to just use the one connection when publishing to the web.

At the moment the DAL referenced project works on the web application if I set the app.config correctly (which only makes some sense to me since its a referenced .dll).

Does adding this DAL.Properties.Settings.DefaultConnection connection to my web.config replace the one the DAL is using?

4

1 回答 1

1

Web 应用程序的所有设置都将来自 web.config 文件 - app.config 不会与 Web 应用程序一起使用或部署。最有可能的是,该配置存在,因为您使用的是实体框架,而这正是 EDMX 功能存储它的连接字符串的地方。如果您将连接字符串放在 web.config 中(并使用适当的配置转换),那么您应该很好。

于 2013-06-03T16:08:29.903 回答