Skip to content

Instantly share code, notes, and snippets.

Last active March 9, 2018 21:08
Show Gist options
  • Save saurabh500/7aea92c5bd0f2ad3d12f1dd751e6aec8 to your computer and use it in GitHub Desktop.
Save saurabh500/7aea92c5bd0f2ad3d12f1dd751e6aec8 to your computer and use it in GitHub Desktop.
Instructions to run the Entity Framework Core tests

The following steps should be followed to run the Entity Framework tests and how to run the tests with modified SqlClient.

  1. Clone the repo
  2. Build the repo using build.cmd or depending on the OS you are on.

Make a note of the dotnet path that the build is using. This will be needed to execute specific tests

E.g. In the following the path is C:\Users\sausing.dotnet\x64\dotnet.exe

D:\aspnet\EntityFrameworkCore>build --help
Using KoreBuild 2.1.0-preview1-15661
WARNING: dotnet found on the system PATH is 'C:\Program Files\dotnet\dotnet.exe' but KoreBuild will use
WARNING: Adding 'C:\Users\sausing\.dotnet\x64' to system PATH permanently may be required for applications like
Visual Studio or VS Code to work correctly.
Adding C:\Users\sausing\.dotnet\x64 to PATH
.NET Core runtime 2.0.3 is already installed. Skipping installation.

Executing Sql Server related Entity Framework tests

The SqlServer related tests are in the folder test/EFCore.SqlServer.FunctionalTests

Navigate to the folder above

Modify the config.json to pass in a valid connection string. Please note that the connection string should point to a server which is prefereably empty and has no databases configured.

Using the dotnet command recorded during build run the following:

  1. To run all the tests in the folder PathTodotnet.exe test --framework netcoreapp2.0

  2. To run a specfic tests PathTodotnet.exe test --framework netcoreapp2.0 --filter="FullyQualifiedName=NameSpace.Class.Method"

To skip building the tests every time, using the --no-build flag with dotnet command E.g. PathTodotnet.exe test --framework netcoreapp2.0 --no-build --filter="FullyQualifiedName=NameSpace.Class.Method"

Testing SqlClient changes

After building a modified version of SqlClient you need to place the SqlClient at the nuget package cache folder for EF tests to pick.

First step is to figure out what version of SqlClient EF is using.

  1. Find build/dependencies.props in the EF clone.
  2. SqlClient version is listed in XML tag which looks like <SystemDataSqlClientPackageVersion>4.5.0-preview2-26130-01</SystemDataSqlClientPackageVersion>

Assuming you are using default Nuget Package Cache path On Windows the DLL to replace should be in the %userprofile%.dotnet folder where the dotnet runtime is downloaded by EF tests

On Linux , the package cache is available at ~/.dotnet/sdk/NuGetFallbackFolder/

Replace the SqlClient at the above path with the one you built and reexecute tests.

Note: The path mentioned above keeps changing from runtime to runtime. I recommend that you run the tests with --no-build option after renaming the System.Data.SqlClient.dll to System.Data.SqlClient.dll_ to make sure that test crash. This would mean that the System.Data.SqlClient.dll was not found and you have found the right location for the DLL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment