2
I am using EF6 Code First. While performing "Update-Database" the database is normally created. But when entering the data the following error is launched:
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.
On Web.config I put the Connection string with the Provider:
<connectionStrings>
<add name="StringSqlServerConnection" connectionString="Data Source=NOTE-RAPHAEL\SQLEXPRESS;Initial Catalog=ProjetoTesteDb;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
I put this setting below that I saw in a tutorial from Microsoft, but with it the program didn’t even open:
<configSections>
<section name="entityFramework"
type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
Connection class:
public class AppContext : DbContext
{
public AppContext()
: base("StringSqlServerConnection")
{ }
...
}
I have other projects that are with this same configuration and had no problem.
puts your connection class to see how to pass in the constructor , ta doing in separate layer ?
– Eduardo Sampaio
I put Eduardo. Yes I’m using it in separate layers with Repository Pattern.
– Raphael
@Raphael , what is the need to use Repository Pattern?
– Renan Carlos
Hello Renan. It would be to leave isolated the layer of business rules of the bank layer. (Separate responsibilities).
– Raphael