I know there is a problem with EF6 EntityFramework.SqlServer and included var type = typeof(System.Data.Entity.SqlServer.SqlProviderServices);
in context constructor. It works fine when i do publish in DEBUG mode.
Getting the below error only when I publish in RELEASE mode. The reason is EntityFramework.SqlServer.dll
missing in the published folder. But, bin folder has EntityFramework.SqlServer.dll for both debug and release mode.
Error:
The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application.
Why is it missing only when I publish using RELEASE mode?
Don't know why; but adding this method to your context will make your project copy the dll
private void FixEfProviderServicesProblem()
{
// The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer'
// for the 'System.Data.SqlClient' ADO.NET provider could not be loaded.
// Make sure the provider assembly is available to the running application.
// See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
var instance = System.Data.Entity.SqlServer.SqlProviderServices.Instance;
}
Tested and working Reference: Entity Framework Provider type could not be loaded?