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

后端 未结 10 2042
旧巷少年郎
旧巷少年郎 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);
    }
    

提交回复
热议问题