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.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3