-
Notifications
You must be signed in to change notification settings - Fork 56
Home
The NuGet package EfCore.TestSupport is a library containing methods to help you unit test applications that use Entity Framework Core for database access. The examples in this documentation uses xUnit, but these methods can be used with other unit test packages.
Since the release of EF Core 5 I couldn't differentiate between EF Core version using netstandard, so from EF Core 5 onward the first number in the version number of this library defines what version of EF Core it works for. So
- EfCore.TestSupport, version 5.?.? works with EF Core 5 and 6.
- EfCore.TestSupport, version 3.2.0 works with EF Core 2.1, 3.0, and 3.1
This documentation is for EfCore.TestSupport version 5 or above, which only works for EF Core 5.0.1 and above.
NOTE: If you are looking for the EfSchemaCompare feature, it now has its own EfCore.SchemaCompare project/NuGet package.
This wiki defines the various groups and the signatures of the methods. The various groups of methods are listed below (see sidebar for links):
- Helpers to create connection strings with a unique database name (via appsetting.json)
- Methods to create EF Core databases
- SQLite in-memory databases
- SQL Server databases
- Cosmos DB emulator databases
- Add EF Core logging to any of the database types
- Various tools for getting test data, or file paths to test data
- A tool for applying a SQL script file to a EF Core database
- xUnit Fluent Validations.
This GitHub repository contains the source of the The NuGet package
EfCore.TestSupport is the project TestSupport
and various unit tests that check the project TestSupport
.
If are using the older versions of EF Core like that supports EF Core 2.1, 3, and 3.1, then you need EfCore.TestSupport, Version 3.2.0. The documentation for this older version can be found via the Version 3.2.0 docs link.
- Testing against a PostgreSQL db
- Changes in EfCore.TestSupport 5
- Testing with production data
- Using an in-memory database (old)