Where should I put ConnectionString in Windows Forms with EF?

2

I'm having the following error using Entity Framework:

  

Additional information: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'. Make sure the provider is registered in the 'entityFramework' section of the application config file. See link for more information.

I found this error EF did not find my ConnectionString and uses the default

Data Source=.\SQLEXPRESS;Initial Catalog=ResenhaInformalContext;Integrated Security=True;MultipleActiveResultSets=True

I'm using a WINDOWS FORMS APPLICATION and an CLASS LIBRARY infrastructure already put the ConnectionString in App.Config, both the Class Library where the Entity Framework is installed , and in the WF that is where the application start happens.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="ResenhaInformalContext" connectionString="Data Source=RENAN-   NB\ESPACOCULTURA;Initial Catalog=ResenhaInformalContext;Persist Security     Info=True;User ID=sa;Password=renan010203;MultipleActiveResultSets=True"      providerName="System.Data.SqlClient" />
</connectionStrings>

How can I resolve this error?

    
asked by anonymous 26.08.2016 / 23:23

1 answer

2

You need to have the Entity Framework referenced also in your main project.

It's important to note that the connection string will be used in the app.config (or web.config ) it is also worth to run migrations, the connection string will always be the project that is marked as startup project .

    
29.08.2016 / 17:51