GrumpTech.EntityWebApi.Dtos 0.1.2

Prefix Reserved
dotnet add package GrumpTech.EntityWebApi.Dtos --version 0.1.2
                    
NuGet\Install-Package GrumpTech.EntityWebApi.Dtos -Version 0.1.2
                    
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="GrumpTech.EntityWebApi.Dtos" Version="0.1.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GrumpTech.EntityWebApi.Dtos" Version="0.1.2" />
                    
Directory.Packages.props
<PackageReference Include="GrumpTech.EntityWebApi.Dtos" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GrumpTech.EntityWebApi.Dtos --version 0.1.2
                    
#r "nuget: GrumpTech.EntityWebApi.Dtos, 0.1.2"
                    
#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.
#:package GrumpTech.EntityWebApi.Dtos@0.1.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=GrumpTech.EntityWebApi.Dtos&version=0.1.2
                    
Install as a Cake Addin
#tool nuget:?package=GrumpTech.EntityWebApi.Dtos&version=0.1.2
                    
Install as a Cake Tool

EntityWebApi.Dtos

Part of EntityWebApi.

EntityWebApi.Dtos dynamically generates DTO types from Entity Framework Core entity models at runtime. Instead of maintaining separate DTO classes, you can generate them directly from your entities while controlling which properties are included through configuration and attributes.

Features

  • Generate DTO types directly from Entity Framework Core models
  • Configure suffixes
  • Control included properties using attributes
  • Create different DTO variants for read, create, update, and patch operations
  • Automatically exclude generated properties for create/update DTOs

Getting started

Generate a standard DTO set

The following example creates DTO types for common operations:

var typeStore = new DtoBuilder()
    .CreateKeyDtos(dataContext)
    .CreateDtos(dataContext)
    .CreatePostDtos(dataContext)
    .CreatePutDtos(dataContext)
    .CreatePutDtos<PatchDtoPropertyAttribute>(dataContext, false, "PatchDto")
    .Build();

This generates:

Method Purpose
CreateKeyDtos DTOs containing only key properties.
CreateDtos Standard read DTOs.
CreatePostDtos DTOs intended for create (POST) operations.
CreatePutDtos DTOs intended for update (PUT) operations.
CreatePutDtos<PatchDtoPropertyAttribute> Generates PATCH DTOs using a different property attribute and suffix.

The resulting TypeStore contains all generated DTO types and can be used throughout the application.

Custom configuration

DTO generation can be customized using TypeConfiguration.

var typeStore = new DtoBuilder()
    .CreateDtos(dbContext,
        new TypeConfiguration
        {
            Suffix = "Dto",
            NavigationSuffix = "Dto",

            DefaultIncludes = EntityPropertyTypes.None,
            IgnoreAttribute = EntityPropertyTypes.None,

            SkipAutoGeneratedPropertiesOnAdd = true,
            SkipAutoGeneratedPropertiesOnUpdate = true,
        }
        .SetAttributeType<TDtoPropertyAttribute>())
    .Build();

Configuration options

Property Description
Suffix Suffix appended to generated DTO type names.
NavigationSuffix Navigation property DTOs are the DTOs ending with this suffix.
DefaultIncludes Controls which property types are included by default.
IgnoreAttribute Specifies which properties are ignored during generation.
SkipAutoGeneratedPropertiesOnAdd Excludes database-generated properties from create DTOs.
SkipAutoGeneratedPropertiesOnUpdate Excludes database-generated properties from update DTOs.
SetAttributeType<T>() Specifies the attribute type used to control property inclusion.

Property attributes

Property inclusion (or exclusion) can be customized by supplying your own attribute type:

.SetAttributeType<MyDtoPropertyAttribute>()

This allows different DTO variants to expose different subsets of properties while reusing the same entity model.

Build

After configuring all DTO variants, call Build() to create a TypeStore containing the DTOs.

var typeStore = new DtoBuilder()
    // DTO configurations...
    .Build();

The resulting TypeStore can then be used by EntityWebApi when resolving DTO types.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
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
0.1.2 113 7/31/2026
0.1.1 102 7/20/2026
0.1.0 107 7/19/2026