1
votes

I want to use EF6 inside a C# Com visible DLL that I use in my VB6 application, but experience an error. Note I am not using app.config , rather I am passing the connection string in from the VB6 program.

Inside the C# code I access the DBContext as follows;

private static MyDataEntities CreateDb()
{ 
    return new MyDataEntities(EFConnectionString);
}

EFConnectionString is

"metadata=res://*/vivModel.csdl|res://*/vivModel.ssdl|res://*/vivModel.msl;provider=System.Data.SqlClient;provider connection string='data source=MYPC\SQL2008R2;initial catalog=MyDatabase;user id=sa;password=mypassword;MultipleActiveResultSets=True;App=EntityFramework'"

The error message is

[[Schema specified is not valid. Errors: vivModel.ssdl(2,2) : error 0152: 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.]]

3

3 Answers

6
votes

I had the same error using VS 2013, EF 6.1.1, in a solution with N-tier with two Web Application projects and one class library. I have installed EF just in this class library. I solved the problem when I installed the EF in the Web Application projects too. After that, the EntityFramework.sqlserver.dll was found in the folder bin/debug. I found the solution in another stackoverflow question.

2
votes

I have been able to get past this error by copying the dlls from the packages folder to the same folder as my vb executable. EntityFramework.sqlserver.dll was not finding its way to bind\debug

0
votes

Two DLL file must be added in Bin folder 1. EntityFramework.SqlServer.dll 2. EntityFramework.dll

Note: if both are added in dll then check your dll