Home >Backend Development >C++ >Why Does My Unit Test Fail with 'The Entity Framework provider type... could not be loaded?'
Entity Framework Provider Loading Failure
When attempting to run unit tests on TeamCity, an exception arises: "The Entity Framework provider type
'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' for the 'System.Data.SqlClient' ADO.NET provider could not be loaded..."
Resolution
Despite the absence of direct references to System.Data.Entity in project, the presence of specific configuration settings in the app.config file can cause unexpected behavior:
<entityFramework> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> </entityFramework>
This configuration forces the runtime to attempt loading the Entity Framework provider, even without direct references.
Solution
To resolve this issue, ensure that the EntityFramework.SqlServer NuGet package is installed in all executables involved in the test process. Additionally, remove the entityFramework section from the app.config file, as it is no longer necessary.
The above is the detailed content of Why Does My Unit Test Fail with 'The Entity Framework provider type... could not be loaded?'. For more information, please follow other related articles on the PHP Chinese website!