Search code examples
entity-frameworkcomvb6

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


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


Solution

  • 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