I have a solution with 3 projects. A console project and two class library projects.
Each class project has an EDM item added with one Entity.
So I use Model First approach.
Each class project has its own app.config with:
<connectionStrings>
<add name="FilingDBContainer" connectionString="Data Source=TESTPC\SQLEXPRESS;Initial Catalog=Test;Integrated Security=True;Pooling=False" />
</connectionStrings>
<connectionStrings>
<add name="ResponderDBContainer" connectionString="Data Source=TESTPC\SQLEXPRESS;Initial Catalog=Test;Integrated Security=True;Pooling=False" />
</connectionStrings>
In the console project which I can run I have this code:
var fileContext = new FilingDBContainer();
var files = fileContext.FileSet;
for (int i = 0; i < 10; i++)
{
files.Add(new File { Id = i + 1, Filename = "Test" + i });
}
var responderContext = new ResponderDBContainer();
var responders = responderContext.ResponderSet;
for (int i = 0; i < 10; i++)
{
responders.Add(new Responder { Id = i + 1, Respondername = "Test" + i });
}
When the first file is added I get an exception:
No connection string named 'FilingDBContainer' could be found in the application config file.
For me it seems the connectionString should be put in the console project but I do not want to the put con string there. Each class project should have its own con string!
How can I do that?