MS Test DataSource Connection String not working

EricO 26 Reputation points
2022-06-03T21:36:23.56+00:00

Utilizing an MS SQL DB to provide data for my unit tests, I have several TestMethods using the following connection string:

WORKS - [DataSource("Persist Security Info=False;User ID=MyUserId; Password=MyPassword;Initial Catalog=UnitTestData;Server=database-server;Provider=SQLOLEDB", "ValidData")]

The above works but requires my user name/password. Windows authentication should be working, as well although I cannot get the connection string below to work:

DOES NOT WORK - [DataSource("Data Source=database-server; Initial Catalog=UnitTestData; Integrated Security=True; Provider=SQLOLEDB", "ValidData")]

I don't want to use SQLOLEDB as the Provider, I want to System.Data.SqlClient but when I try, I get an error that it's not registered.

I know Windows Authentication should work. In the ctor of this TestClass, I created a new SqlConnection instance, using the non-working connection string and I'm abloe to open a connection to the server.

I think an answer may be to provide a correct value in the Provider= section but I'm unsure what it may be.

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,281 questions
Visual Studio Testing
Visual Studio Testing
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Testing: The act or process of applying tests as a means of analysis or diagnosis.
329 questions
{count} votes