3

I have MVC5 application which has 2 areas: area1 and area2 I'd like to access 2 different db connections per each area. I've tried to add to area1\Views\web.config

    <add name="DefaultConnection_area1" providerName="System.data.SqlClient" connectionString="Data Source=xxx;Initial Catalog=DB_AREA1;Integrated Security=true;MultipleActiveResultSets=True" />

and add to area2\Views\web.config

<add name="DefaultConnection_area2" providerName="System.data.SqlClient" connectionString="Data Source=xxx;Initial Catalog=DB_AREA2;Integrated Security=true;MultipleActiveResultSets=True" />

But I am not able to retrieve DefaultConnection_area1/2 in area1/2 controllers via

ConfigurationManager.ConnectionStrings["DefaultConnection_area1(or 2)"].ConnectionString.

The only thing I can access is connection string from root Web.config

BreteP
  • 71
  • 1
  • 7

0 Answers0