I've been having some trouble getting a unit test to run. In the test, I have a method that does the following:
foreach(var x in context.Examples)
{
eList.Add(new Example());
}
When I run this method, the "in" in the foreach line throws and error reading "Spatial types and functions are not available for this provider because the assembly 'Microsoft.SqlServer.Types' version 10 or higher could not be found."
I looked online and tried fixing the issue by reinstalling Microsoft.SqlServer.Types in the package manager, double checking that it's included in the project's references, and (since this is a unit test application) add the following lines before the foreach loop:
SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);
SqlProviderServices.SqlServerTypesAssemblyName =
"Microsoft.SqlServer.Types, Version=14.0.314.76, Culture=neutral, PublicKeyToken=89845dcd8080cc91";
It still throw the same exception. What's weird is that none of the other instances of a foreach loop throw an exception, only this one. Am I missing something?