EF 5 connection string does not contain the required providerName

0 votes
asked Jul 8, 2013 in Entity Framework by Sundaram

I am using entity framework 5.0 to connect to database. I have added connection string in the app.config file and used the below code to get employee detail from the SQL Server database. But, when I try to access, I am getting the below error

The connection string 'SoftwareRequestContext' in the application's configuration file does not contain the required providerName attribute

Code used to retrieve the value from database.

using (SoftwareRequestContext context = new SoftwareRequestContext())
{
   employee = context.Employee.Find(employeeNumber);
}

Connection string added in app.config

<connectionStrings>
    <add name="SoftwareRequestContext" connectionString="Data Source=TestServer\SQLEXPRESS;Initial Catalog=SoftwareRequestWFDemo;Integrated Security=True" />
 </connectionStrings>
Share

1 Answer

+1 vote
answered Jul 8, 2013 by Aadhira (1,213 points)
reshown Jul 9, 2013 by Aadhira
 
Best answer

Add providerName property in the connection string with value "System.Data.SqlClient" for connecting to SQL Server.

<connectionStrings>
    <add name="SoftwareRequestContext" connectionString="Data Source=TestServer\SQLEXPRESS;Initial Catalog=SoftwareRequestWFDemo;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>

Your answer

Preview

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
site design / logo / content © 2013 - 2015 pinfaq.com
...