Entity-framework – No Entity Framework provider found – calling a C# Com DLL from within VB6

comentity-frameworkvb6

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.]]

Best Solution

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.