title: Error when adding SQL Server Unit Test item to a Unit Test Project in visual studio 2017
body: <p>When adding a SQL Server Unit Test item to a Unit Test Project in visual studio 2017 I get the following error:</p>
  
  <pre><code>The reference "Microsoft.VisualStudio.QualityTools.UnitTestFramework, 
  Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, 
  processorArchitecture=MSIL" could not be added to the project. 
  This wizard will continue to run, but the resulting project may not build properly.
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/ALe44.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ALe44.jpg" alt="enter image description here"></a></p>
  
  <p>The project seems to build fine afterwards, but all sql unit tests fail with the following error:</p>
  
  <pre><code>Test Name:  SqlTest1
  Test FullName:  UnitTestProject1.SqlServerUnitTest1.SqlTest1
  Test Source:    c:\[path]\SqlServerUnitTest1.cs : line 34
  Test Outcome:   Failed
  Test Duration:  0:00:00.0278356
  
  Result StackTrace:  
  at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)
     at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
     at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
     at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
     at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
     at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
     at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
  
  Result Message:
    Unable to set TestContext property for the class
    UnitTestProject1.SqlServerUnitTest1. 
    Error: System.ArgumentException: Object of type
    'Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.TestContextImplementation' 
    cannot be converted to type 'Microsoft.VisualStudio.TestTools.UnitTesting.TestContext'..
  </code></pre>
  
  <p><sub>[I've already solved this and will add my fix as an answer below, I'm creating this to document the solution for others that might find it helpful. I'll still be interested if anyone else has experienced this and can shed some light on the cause]</sub></p>