EDennis.AspNetCore.Base 2.8.0

.NET Core 2.2
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package EDennis.AspNetCore.Base --version 2.8.0
NuGet\Install-Package EDennis.AspNetCore.Base -Version 2.8.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EDennis.AspNetCore.Base" Version="2.8.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EDennis.AspNetCore.Base --version 2.8.0
#r "nuget: EDennis.AspNetCore.Base, 2.8.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install EDennis.AspNetCore.Base as a Cake Addin
#addin nuget:?package=EDennis.AspNetCore.Base&version=2.8.0

// Install EDennis.AspNetCore.Base as a Cake Tool
#tool nuget:?package=EDennis.AspNetCore.Base&version=2.8.0


A library that facilities creating testable multi-tier applications in ASP.NET Core


ASP.NET Core MVC and Entity Framework Core collectively provide a great framework for development of enterprise applications. That said, developing integration-testable three-tier applications with these technologies can be a little challenging at times. It is relatively easy to create a web application on one server that communicates with web API on another server, which in turn communicates with a database via Entity Framework; however, to set up proper, repeatable integration tests -- those that completely reset the database (whether in-memory or real) after each test -- is not straightforward, especially when dealing with three-tier solutions. Furthermore, to completely reset the database after spot testing via Swagger UI requires some extra set-up work. Collectively, these challenges motivated development of a library to facilitate testable three-tier application development.


The current library has a number of features that assist with application development:

  • Parallel Architecture for projects that access databases and projects that only access HTTP endpoints. The repository pattern is used for the former type of project. The typed client pattern is used for the latter type of project. Both patterns provide a useful abstraction layer. Both patterns use dependency injection to give controllers access to service objects -- repos and api clients.
  • Base Repository Classes that simplify basic Entity Framework operations but also include support for querying by Dynamic Linq Expressions, Stored Procedures, and raw SQL. Two writeable repo classes are provided that, in conjunction with database management interceptors (see below), can be used with in-memory testing.
  • Base Controller Classes that simplify web API construction and provide numerous capabilities. A WriteableController base class provides Swagger-friendly endpoints for regular CRUD operations, Dynamic Linq, OData, and DevExtreme Load operations. A ReadonlyController class provides Swagger-friendly endpoints for regular Dynamic Linq, OData, and DevExtreme Load operations, as well as Postman-friendly endpoints for executing parameterized stored procedures.
  • Database Management Interceptors (middleware) that look for special header values in HTTP requests in order to create, select, or discard a specific in-memory database. This middleware makes it possible to perform multiple operations on the same in-memory database accessed indirectly through multiple layers of APIs. The interceptors work with both Swagger spot-testing and automated integration testing.
  • Xunit Base Classes and associated factory classes that greatly simplify setup of unit and integration tests of projects that use in-memory databases. These classes support the following scenarios:
    • Repo Tests - direct tests of methods in writeable and readonly repositories, where the writeable repo tests, through configuration only, spin up an in-memory database on the fly
    • Controller Tests - direct tests of controller methods, where no web server is involved, but where (through configuration only) an in-memory database may be spun up on the fly
    • Endpoint Tests - tests of controller methods where one or more web servers are spun up on the fly, each optionally (through configuration only) with its own in-memory or regular SQL database
    • ApiClient Tests - direct tests of methods in ApiClient and SecureApiClient classes, which require one or more web servers to be spun up on the fly, each optionally (through configuration only) with its own in-memory or regular SQL database
  • Security Utilities that perform the following functions:
    • AutologinMiddleware, which allows configuration of users that can be automatically logged on during different launch configurations
    • MockClientAuthorizationMiddleware for IdentityServer, which allows configuration of OAuth clients for which access tokens are automatically generated during different launch configurations (especially helpful if you are spot-testing with Swagger)
    • AddDefaultAuthorizationPolicyConvention, which automatically adds Authorize policies to controllers and action methods (obviating the need for the Authorize attribute)
    • AddClientAuthenticationAndAuthorizationWithDefaultPolicies, which is an IServiceCollection extension method that uses reflection to automatically assign default, scope-defined policies to controllers and action methods.
  • Temporal Entities -- entity-framework-driven support for history tables. This support was inspired by SQL Server temporal tables; however, the EF implementation makes it possible to do time-travel queries using entity framework. Several base repository methods are provided to support such queries. In addition, the EF implementation makes it possible to record the user who deleted a record -- something that requires a little more work with SQL Server temporal tables.
  • ApiLauncher -- a main class (and supporting classes) that uses configuration settings to identify, start, and stop one or more web api projects; assign available random port numbers; ensure that the same project api is started only once; and update the BaseAddress of all associated HttpClients (following the typed client pattern). Importantly, the ApiLauncher launches all APIs within the same execution context as the main project, making it possible to debug into the Apis, even during automated integration testing. This utility class is especially helpful when you have multiple APIs that each use IdentityServer.
  • Numerous IServiceCollection Extension Methods that simplify the setup of Dependency Injection for
    • Typed HttpClients
    • DbContexts
    • Repository classes
  • Numerous HttpClient Extension methods that simplify basic Http operations such as posting, putting, deleting, or getting any object of type T

Associated Projects

  • This project has classes that replace all of the functionality provided by EDennis.EFBase
  • This project is designed to work with EDennis.MigrationsExtensions, which provides assistance in performing Entity Framework migrations. In particular, the library provides a MigrationBuilder extension method called SaveMappings, which saves Table/Class and Column/Property mappings to SQL Server extended properties.
  • This project is designed to work with EDennis.NetCoreTestingUtilities, which provides many helpful classes for performing unit/integration tests.
  • The EDennis.DataScaffolder project provides a WinForms application that generates static data for the "HasData" method. When the EDennis.MigrationsExtensions SaveMappings extension method is used (see above), the static data have correct class names and property names.
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.2 is compatible.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.1.2-alpha 380 3/12/2020
3.1.1-alpha 399 2/24/2020
3.1.0-alpha 374 2/24/2020
2.8.0 705 10/17/2019
2.7.9 624 10/16/2019
2.7.8 602 10/15/2019
2.7.7 573 10/15/2019
2.7.6 595 10/14/2019
2.7.5 646 9/25/2019
2.7.4 596 9/19/2019
2.7.3 589 9/13/2019
2.7.1 611 9/12/2019
2.7.0 647 9/12/2019
2.6.2 569 9/3/2019
2.6.1 596 9/3/2019
2.6.0 608 8/30/2019
2.5.2 616 7/23/2019
2.5.1 606 7/15/2019
2.5.0 655 7/10/2019
2.4.8 614 6/19/2019
2.4.7 599 6/18/2019
2.4.6 615 6/18/2019
2.4.5 602 6/13/2019
2.4.4 632 6/5/2019
2.4.2 652 5/21/2019
2.3.0 626 5/8/2019
2.2.9 655 5/8/2019
2.2.8 587 5/7/2019
2.2.7 633 5/3/2019
2.2.6 640 5/3/2019
2.2.5 729 5/2/2019
2.2.4 715 5/2/2019
2.2.3 684 4/29/2019
2.2.2 660 4/24/2019
2.2.1 715 4/23/2019
2.2.0 711 4/22/2019
2.1.3 684 4/14/2019
2.1.2 662 4/6/2019
2.1.1 1,233 4/5/2019
2.1.0 1,202 4/3/2019
2.0.0 1,426 4/2/2019
1.4.5 1,180 3/29/2019
1.4.4 1,395 3/28/2019
1.4.3 1,431 3/28/2019
1.4.2 1,302 3/27/2019
1.4.1 1,429 3/26/2019
1.4.0 1,422 3/23/2019
1.3.7 1,211 3/19/2019
1.3.6 1,412 3/18/2019
1.3.5 1,409 3/12/2019
1.3.4 1,389 3/9/2019
1.3.3 1,346 3/8/2019
1.3.1 886 1/18/2019
1.3.0 838 1/18/2019
1.2.0 830 1/16/2019
1.1.0 767 12/28/2018
1.0.0 826 12/26/2018

Added support for X-Testing:UseRelational header