No Entity Framework provider found for the ADO.NET

2019-01-01 09:35发布

After downloading the EF6 by nuget and try to run my project, it returns the following error:

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 http://go.microsoft.com/fwlink/?LinkId=260882 for more information.

enter image description here

30条回答
君临天下
2楼-- · 2019-01-01 10:28

I have just re-installed the Entity Framework using Nuget. And follow the instruction written on the link below : http://robsneuron.blogspot.in/2013/11/entity-framework-upgrade-to-6.html

I think the problem will get solved.

查看更多
无与为乐者.
3楼-- · 2019-01-01 10:28

I have the same error. It's weird that it only happens whenever I used my dbContext to query to any of my model or get its list like:

var results = _dbContext.MyModel.ToList();

We tried to reinstall the Entity Framework, reference it properly but to no avail.

Luckily, we tried to check the Nuget for ALL solutions, then update everything or make sure everything is the same version because we noticed that the two projects has different EF versions on the Web project. And it works. The error is gone.

Here is the screenshot on how to Manage Nuget for all solutions:

enter image description here

查看更多
余生请多指教
4楼-- · 2019-01-01 10:28

it looks like nobody mentioned first checking if System.Data.SqlClient is installed in the system and if a reference is made to it.

i solved my issue by installing System.Data.SqlClient and adding in a new provider in app.Config

<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6"/>
查看更多
美炸的是我
5楼-- · 2019-01-01 10:29

None of these worked for me. I did find the solution in another stackoverflow question. I'll add it here for easy reference:

You need to make a reference, so it will be copied in den application path. Because later it will be referenced in runtime. So you don't need to copy any files.

private volatile Type _dependency;

public MyClass()
{
    _dependency = typeof(System.Data.Entity.SqlServer.SqlProviderServices);
}
查看更多
高级女魔头
6楼-- · 2019-01-01 10:29

When the error happens in tests projects the prettiest solution is to decorate the test class with:

[DeploymentItem("EntityFramework.SqlServer.dll")]
查看更多
浅入江南
7楼-- · 2019-01-01 10:29

As message shows that we need to add provider System.Data.SqlClient that's why we need to install nuget package of EntityFramework that has two dll but if we are developing only console application then we just need to add reference of EntityFramework.SqlServer.dll

查看更多
登录 后发表回答