I\'ve written a T4 template where I instantiate an EF context to read some data. The problem is that the context cannot see the connection string from the Web.config.
Ho
I accessed a connection string from App.config from T4 template in the following way:
<#@ template debug="false" hostspecific="true" language="C#" #>
ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap(this.Host.ResolvePath(@"..\ProjName\App.config"));
configFileMap.ExeConfigFilename = this.Host.ResolvePath(@"..\ProjName\App.config");
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None);
string connectionString = config.ConnectionStrings.ConnectionStrings[0].ConnectionString;