ClearBlueDesign.EntityFrameworkCore.Scaffolder 1.0.0-alpha7

.NET Core 3.1
This is a prerelease version of ClearBlueDesign.EntityFrameworkCore.Scaffolder.
NuGet\Install-Package ClearBlueDesign.EntityFrameworkCore.Scaffolder -Version 1.0.0-alpha7
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.
dotnet add package ClearBlueDesign.EntityFrameworkCore.Scaffolder --version 1.0.0-alpha7
<PackageReference Include="ClearBlueDesign.EntityFrameworkCore.Scaffolder" Version="1.0.0-alpha7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ClearBlueDesign.EntityFrameworkCore.Scaffolder --version 1.0.0-alpha7
#r "nuget: ClearBlueDesign.EntityFrameworkCore.Scaffolder, 1.0.0-alpha7"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install ClearBlueDesign.EntityFrameworkCore.Scaffolder as a Cake Addin
#addin nuget:?package=ClearBlueDesign.EntityFrameworkCore.Scaffolder&version=1.0.0-alpha7&prerelease

// Install ClearBlueDesign.EntityFrameworkCore.Scaffolder as a Cake Tool
#tool nuget:?package=ClearBlueDesign.EntityFrameworkCore.Scaffolder&version=1.0.0-alpha7&prerelease


This is an Entity Framework Core 2.1+ extension for the Microsoft Scaffold-DbContext database-first scaffolder that allows you to:

  • Use lazy loading for all related entities (virtual keyword)
  • Use EFCore.Pluralizer entity name pluralizer by Brice Lambson
  • Change the base class of the generated MyDbContext class (as may be needed when integrating with the IdentityServer)
public partial class MyDbContext 
	: IdentityDbContext<User, Role, int, UserClaim, UserRole, UserLogin, RoleClaim, UserToken>
  • Import additional assemblies as part of the generated MyDbContext class (e.g. using Microsoft.AspNetCore.Identity.EntityFrameworkCore;)
  • Override base classes and interfaces of any of the generated entities (for integration with libraries like IdentityServer and implementation of IAuditableEntity-style interfaces)
public partial class User : IdentityUser<int>, IAuditableEntity
public partial class Vehicle : IAuditableEntity


  1. Add the following package to your startup project:
Install-Package ClearBlueDesign.EntityFrameworkCore.Scaffolder -Pre
  1. Add scaffolder.json file at the root of the project and configure custom scaffolding options as needed.
  2. Add DesignTimeServices.cs file containing DesignTimeServices class that implements IDesignTimeServices interface (so that the ClearBlueDesign.EntityFrameworkCore.Scaffolder is injected into Scaffold-DbContext pipeline):
public class DesignTimeServices : IDesignTimeServices {
	public void ConfigureDesignTimeServices(IServiceCollection services) {
  1. Run scaffolding command with the desired base scaffolder parameters:
	-Context "MyDbContext" 
	-ContextDir "Data" 
	-OutputDir "Data\Entities" 
	-Tables "Product","ProductNote","ProductHistory" 

Custom Scaffolding Options (scaffolder.json)

This scaffolder extension supports all of the official Scaffold-DbContext options (see here).

All of the new scaffolder options should be specified inside the scaffolder.json file at the root of the project:

	"Scaffolding": {
		"UsePluralizer": true,
		"UseDataAnnotations": false

	"DbContext": {
		"Base": "DbContext"

	"EntityType": {
		"UseLazyLoading": true,
		"BaseMappings": {
			"<TableName1>": [ "MyBaseClass1", "IContract" ],
			"<TableName2>": [ "MyGenericClass1<Int32>", "IContract" ]
			"<TableName3>": [ "IContract" ]
		"PropertyMappings": {
			"<EntityTypeA>": {
				"<ColumnNameA>": "<PropertyNameA>",
				"<ColumnNameB>": "<PropertyNameB>",
			"<EntityTypeB>": {
				"<ColumnNameC>": "<PropertyNameC>",
				"<ColumnNameD>": "<PropertyNameD>",
		"LoadAssemblies": [


  • Add support for entity-level data validations using partial entity classes with validation attributes ([MetadataObject(typeof(Vehicle.Metadata)], [AssertThat], [RequiredIf], etc), IValidatableObject, and ValidateEntity override on the generated MyDbContext.
  • Add support for scaffolding of stored procedures into the generated MyDbContext using query types.


Want to file a bug, contribute some code, or improve documentation? Excellent! Read up on our guidelines for contributing and then check out one of our issues in the hotlist: community-help.


This project is licensed under the MIT license.

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp3.1
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
1.0.0-alpha7 885 7/1/2020
1.0.0-alpha6 237 6/29/2020
1.0.0-alpha5 757 12/12/2019
1.0.0-alpha4 270 12/12/2019
1.0.0-alpha3 271 12/3/2019
1.0.0-alpha.2 3,731 12/3/2018
1.0.0-alpha.1 453 11/27/2018