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

connection-string ef-code-first entity-framework

Question

I use Entity Framework Code First,

My connection string is in a configuration file:

<connectionStrings>
    <clear/>
    <add name="ApplicationServices" connectionString="Data Source=PC-X;Initial Catalog=MYdb;Integrated Security=True"/>
  </connectionStrings>

When I try to access the data (something that should create the DB) is falling with the following error:

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

What am I missing?

1
82
7/12/2019 7:35:56 AM

Accepted Answer

You're missing the following piece of code after the connectionString attribute (assuming that you're using SQL):

providerName="System.Data.SqlClient"

174
2/25/2013 2:54:55 PM

Popular Answer

Sometime in the future. the complete code

<add name="YouContext" connectionString="Integrated Security=True;Persist Security Info=False;Initial Catalog=YourDatabaseName;Data Source=YourPCName;" providerName="System.Data.SqlClient"/>


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow