0
votes

I've run into some issues with MSTest when they're run inside teamcity. When I run them inside VisualStudio on local machine, everything works good.

[08:05:21][ProjName.Data.Tests.HistoryTableHandlingTest.HistoryProgressTest] Class Initialization method ProjName.Data.Tests.HistoryTableHandlingTest.Init threw exception. System.InvalidOperationException: System.InvalidOperationException: The 'Instance' member of the Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' did not return an object that inherits from 'System.Data.Entity.Core.Common.DbProviderServices'. Entity Framework providers must inherit from this class and the 'Instance' member must return the singleton instance of the provider. This may be because the provider does not support Entity Framework 6 or later; see http://go.microsoft.com/fwlink/?LinkId=260882 for more information..

Here's my app.config for MSTest project:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral" requirePermission="false" />
  </configSections>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
</configuration>

Another thing that I'd like to mention is, that I don't use EntityFramework library from NuGet, but it's clone EntityFramework.HierarchyId (it can be found in NuGet as well).

1
Can you try using the standard EntityFramework library to see if the issue still occurs? It might be helpful to rule that out first.John Hoerr
Since I use HierarchyId in my code, this could be a problem...Tomino

1 Answers

0
votes

After I rewrote all tests to NUnit, I got the same results. But it seems, that the main reason of this behavior was, that on the build agent MS Sql Server Express wasn't installed properly. When I re-installed latest version of SQL Express, everything started to work as a sharm. It seems that system was missing some drivers or libraries for LocalDB.

I hope that this will help someone else.