Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to determine the provider name for provider factory of type > 'System.Data.SqlClient.SqlClientFactory'

Attempting to run integration tests in a project using Entity Framework 6 resulted in the error:

SetUp : System.NotSupportedException : Unable to determine the provider name for provider factory of type 'System.Data.SqlClient.SqlClientFactory'. Make sure that the ADO.NET provider is installed or registered in the application config.

But the tests on same project works absolutely fine on several of my colleagues' machines and I have no local changes.

Have attempted reinstalling EF, I don't have any unnecessary config sections or Glimpse and I've tried targeting a different version of the framework but the error persists...

like image 314
Stelloy Avatar asked Sep 08 '15 15:09

Stelloy


Video Answer


1 Answers

It turns out I have an empty, duplicate DbProviderFactories element in both my Framework/Framework64 machine.config files, which appears to have been created by the installation of the IBM DB2 .NET provider (?!). The duplicate node is rendering the machine.config invalid, so the issue is localised to my machine.

Modifying

<DbProviderFactories>
    <add name="IBM DB2 for i5/OS .NET Provider" invariant="IBM.Data.DB2.iSeries" description=".NET Framework Data Provider for i5/OS" type="IBM.Data.DB2.iSeries.iDB2Factory, IBM.Data.DB2.iSeries, Version=12.0.0.0, Culture=neutral, PublicKeyToken=9cdb2ebfb1f93a26"/>
    <add name="Microsoft SQL Server Compact Data Provider" invariant="System.Data.SqlServerCe.3.5" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=3.5.1.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/><add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
</DbProviderFactories>
<DbProviderFactories/>

to remove the extra node:

<DbProviderFactories>
    <add name="IBM DB2 for i5/OS .NET Provider" invariant="IBM.Data.DB2.iSeries" description=".NET Framework Data Provider for i5/OS" type="IBM.Data.DB2.iSeries.iDB2Factory, IBM.Data.DB2.iSeries, Version=12.0.0.0, Culture=neutral, PublicKeyToken=9cdb2ebfb1f93a26"/>
    <add name="Microsoft SQL Server Compact Data Provider" invariant="System.Data.SqlServerCe.3.5" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=3.5.1.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/><add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
</DbProviderFactories>      

Resolved the issue.

like image 85
Stelloy Avatar answered Oct 11 '22 20:10

Stelloy