NetSchema.Library 1.0.8

There is a newer version of this package available.
See the version list below for details.
dotnet add package NetSchema.Library --version 1.0.8
                    
NuGet\Install-Package NetSchema.Library -Version 1.0.8
                    
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="NetSchema.Library" Version="1.0.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NetSchema.Library" Version="1.0.8" />
                    
Directory.Packages.props
<PackageReference Include="NetSchema.Library" />
                    
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 NetSchema.Library --version 1.0.8
                    
#r "nuget: NetSchema.Library, 1.0.8"
                    
#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 NetSchema.Library@1.0.8
                    
#: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=NetSchema.Library&version=1.0.8
                    
Install as a Cake Addin
#tool nuget:?package=NetSchema.Library&version=1.0.8
                    
Install as a Cake Tool

NetSchema.Library

Programmatic N-Tier Code Generator for your .NET applications.

?? Status: Package is ready but not yet published to NuGet.org.
See PUBLISH-GUIDE.md for publish instructions.


?? Installation (After Publish)

dotnet add package NetSchema.Library

?? Quick Start

Step 1: Install Package

cd YourSolution
dotnet new console -n YourApp.CodeGen
cd YourApp.CodeGen
dotnet add package NetSchema.Library
dotnet add reference ../YourApp.Core/YourApp.Core.csproj

Step 2: Write Code Generator

// YourApp.CodeGen/Program.cs
using NetSchema.Library;
using YourApp.Core.Entities;

// ? Solution path is auto-detected!
NetSchema.Configure()
    .AddEntity<User>()
    .AddEntity<Product>()
    .AddEntity<Order>()
    .GenerateAll();

Console.WriteLine("? Code generated successfully!");

Step 3: Run

dotnet run

Done! All DTOs, Validators, Repositories, Services, and Controllers are generated! ??


?? Usage Examples

using NetSchema.Library;
using YourApp.Core.Entities;

// No path needed - automatically finds solution!
NetSchema.Configure()
    .AddEntity<User>()
    .AddEntity<Product>()
    .GenerateAll();

Example 2: Specify Solution Path Manually

var solutionPath = @"C:\Projects\YourApp";

NetSchema.Configure(solutionPath)
    .AddEntity<User>()
    .AddEntity<Product>()
    .GenerateAll();

Example 3: Use Entity Type Array

var entityTypes = new[]
{
    typeof(User),
    typeof(Product),
    typeof(Order),
    typeof(Customer)
};

// With auto-detect
NetSchema.Generate(entityTypes);

// Or with custom path
NetSchema.Generate(@"C:\Projects\YourApp", entityTypes);

Example 4: Auto-Discover All Entities

using System.Reflection;
using NetSchema.Library;
using YourApp.Core.Entities;

var entityTypes = Assembly.GetAssembly(typeof(BaseEntity))
    ?.GetTypes()
    .Where(t => t.IsClass 
             && !t.IsAbstract 
             && t.IsSubclassOf(typeof(BaseEntity)))
    .ToArray() ?? Array.Empty<Type>();

Console.WriteLine($"?? Found {entityTypes.Length} entities");

var builder = NetSchema.Configure();
foreach (var type in entityTypes)
{
    builder.AddEntities(type);
}
builder.GenerateAll();

Example 5: Selective Generation

NetSchema.Configure()
    .AddEntity<User>()
    .Configure(
        repositories: true,   // ? Generate
        services: true,       // ? Generate
        controllers: false,   // ? Skip
        dtos: true,          // ? Generate
        validators: true     // ? Generate
    )
    .GenerateAll();

?? Your Entity Structure

// App.Core/Entities/BaseEntity.cs
public abstract class BaseEntity
{
    public int Id { get; set; }
}

// App.Core/Entities/IAuditedEntity.cs
public interface IAuditedEntity
{
    DateTime CreatedDate { get; set; }
    DateTime? UpdatedDate { get; set; }
    bool IsDeleted { get; set; }
}

// App.Core/Entities/User.cs
public class User : BaseEntity, IAuditedEntity
{
    [Required]
    [MaxLength(100)]
    public string FullName { get; set; } = string.Empty;

    [Required]
    [EmailAddress]
    public string Email { get; set; } = string.Empty;

    public DateTime DateOfBirth { get; set; }
    public bool IsActive { get; set; }

    // Navigation properties (excluded from DTOs)
    public List<Order> Orders { get; set; } = new();

    // Audit fields
    public DateTime CreatedDate { get; set; }
    public DateTime? UpdatedDate { get; set; }
    public bool IsDeleted { get; set; }
}

?? What Gets Generated

For each entity (e.g., User), NetSchema generates:

?? DTOs

App.Business/DTOs/
  ??? UserDto.cs           ? Read
  ??? CreateUserDto.cs     ? Create
  ??? UpdateUserDto.cs     ? Update

? Validators (FluentValidation)

App.Business/Validators/
  ??? CreateUserValidator.cs
  ??? UpdateUserValidator.cs

??? Repositories

App.DAL/Repositories/
  ??? Interfaces/IUserRepository.cs
  ??? Implementations/UserRepository.cs

?? Services

App.Business/Services/
  ??? Interfaces/IUserService.cs
  ??? Implementations/UserService.cs

?? Controllers

App.API/Controllers/
  ??? UserController.cs    ? Full CRUD endpoints

?? Complete Example

using System;
using NetSchema.Library;
using App.Core.Entities;

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("?? NetSchema Code Generator");
        Console.WriteLine("??????????????????????????????????????");
        Console.WriteLine();

        // Generate code for your entities
        var result = NetSchema.Configure()
            .AddEntity<User>()
            .AddEntity<Product>()
            .AddEntity<Order>()
            .GenerateAll();

        // Check result
        if (result.Success)
        {
            Console.WriteLine($"? {result.Message}");
            Console.WriteLine($"?? Generated {result.GeneratedFiles.Count} files:");
            foreach (var file in result.GeneratedFiles)
            {
                Console.WriteLine($"  � {file}");
            }
        }
        else
        {
            Console.WriteLine($"? {result.Message}");
            foreach (var error in result.Errors)
            {
                Console.WriteLine($"  � {error}");
            }
        }
    }
}

?? NetSchema vs NetSchema.Library

Feature NetSchema (CLI Tool) NetSchema.Library (This)
Purpose Create new N-tier project Add code to existing project
Usage netschema generate Code in your app
Installation dotnet tool install dotnet add package
Solution Path Auto Auto or manual
Entities Sample entities Your entities
Best For New projects Existing projects

?? CLI Tool Alternative

If you want to create a complete new project structure:

dotnet tool install --global NetSchema
mkdir MyApp && cd MyApp
dotnet new sln -n MyApp
netschema generate

This creates 5 projects: Core, DAL, Business, API, Shared.


? Current Status

  • ? Package built: NetSchema.Library.1.0.0.nupkg
  • ? Awaiting NuGet.org publish
  • ? Not yet available on NuGet.org

For Now: Use Local Reference

<ItemGroup>
  <ProjectReference Include="..\..\NetSchema.Library\NetSchema.Library.csproj" />
</ItemGroup>

See PUBLISH-GUIDE.md for publish instructions.



?? License

MIT License - see LICENSE

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser 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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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
1.1.0 221 11/4/2025
1.0.9 204 11/4/2025
1.0.8 195 11/4/2025
1.0.7 210 11/4/2025
1.0.6 219 11/4/2025
1.0.5 210 11/4/2025
1.0.4 222 11/4/2025
1.0.3 209 11/4/2025
1.0.2 198 11/4/2025
1.0.1 211 11/4/2025
1.0.0 203 11/4/2025

Version 1.0.8: CreateSolutionWithEntities now automatically adds entity classes to Core project with validation attributes (Required, MaxLength, Range, Email) preserved. Complete end-to-end automation - pass entity types and get fully working solution.