No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'.

后端 未结 10 1994
旧巷少年郎
旧巷少年郎 2020-12-09 14:37

We are using EntityFramework 6 with Code First. We have a console app that has no reference to EntityFramework but reads the connection string from its App.config. It call

相关标签:
10条回答
  • 2020-12-09 15:15

    You need to create a reference, so it will be copied in the debug folder. So later it can accessed in runtime.

    Don't to copy any files, just create this reference:

    private volatile Type _dependency;
    
    public MyClass()
    {
        _dependency = typeof(System.Data.Entity.SqlServer.SqlProviderServices);
    }
    
    0 讨论(0)
  • 2020-12-09 15:20

    do you have the assembly EntityFramework.SqlServer.dll in your application path? I had the same Problem and after copying the dll into the application path every Thing worked fine.

    0 讨论(0)
  • 2020-12-09 15:21

    Finally found the answer in this blog:

    http://robsneuron.blogspot.com/2013/11/entity-framework-upgrade-to-6.html

    0 讨论(0)
  • 2020-12-09 15:21

    The best way to get ride of such a kind of problem is to include the reference EntityFramework.SqlServer.dll into your project the press F4 (op the properties) change the property to Copy to Local =True so each and every time when publish the app it will be copied to the published folder.

    0 讨论(0)
  • 2020-12-09 15:27

    I had this problem too. Everything worked locally when I ran my .net mvc app but when I published it I got this error. The problem was that I had to reference the EntityFrameworl.SqlServer also in my web project alhough I had seperate project for Data. What is strange is that this error was only thrown when app was published. This is some serious bug probably from Microsoft. I used EF 6.1.1.

    0 讨论(0)
  • 2020-12-09 15:27

    I tend to add EntityFramework to the web project as well as the assembly that actually references it.

    0 讨论(0)
提交回复
热议问题