The specified named connection is either not found in the configuration, not intended to be used with the EntityClient p
Posted: Wed 08 Sep 2021 17:19
Using Entity Developer in a class library .NET version 4.7.2 project. When I add an Entity Developer it adds fine, connects to the database ok and builds the code. The connection string is added to the app.config file. All the details of the connection string check out. When I run the class library and use Entity Framework stuff it the following exception happens:
I have confirmed that the connection string in app.config is correct. I have tried to create a completely new Entity Developer item and the new one acts the same. I suspect that this is because the project is a class library??? What should I check?
**EDIT**
It seems that Entity Developer stores the connection string in the app.config file by default. The app.config file is not used in a class library. How to get the connection string in a class library?
My EF code:The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.
Code: Select all
using (var context = new SWPDMEngVaultEntitiesTwo())
{
var docNumber = (from p in context.Projects
join dip in context.DocumentsInProjects on p.ProjectID equals dip.ProjectID
join d in context.Documents on dip.DocumentID equals d.DocumentID
where p.Path == path
&& d.Filename == fileName
&& dip.Deleted == 0
select d.DocumentID).FirstOrDefault();
if (docNumber == 0)
{
throw new Exception("Part ID was not found.");
}
else
{
return docNumber.ToString();
}
}
**EDIT**
It seems that Entity Developer stores the connection string in the app.config file by default. The app.config file is not used in a class library. How to get the connection string in a class library?