ZeraSystems.CodeNanite.Schema
Schema and database-related code nanites for the CodeStencil template engine.
Overview
This package provides specialized code nanites for working with database schemas, tables, columns, views, and DTOs. It extends the core CodeNanite.Expansion functionality with powerful database-specific code generation capabilities.
Features
Column Operations
- ExpandColumnsHorizontally: Expand table columns horizontally in templates
- ExpandModels: Generate model classes from database schemas
- GetColumnCaptions: Retrieve user-friendly column captions
- GetColumnDbTypes: Extract database-specific column types
- GetColumnInputComponent: Generate appropriate input components for columns
- GetColumnNames: Access column names and metadata
- GetColumnTypes: Retrieve .NET types for database columns
- GetPrimaryKey: Identify and work with primary key columns
- ModelColumns: Generate column definitions for models
Table Operations
- CurrentTable: Access current table context in templates
- TableList: Iterate through multiple tables
- GenerateDbSet: Create Entity Framework DbSet properties
- GenerateFluentConfig: Generate Fluent API configurations
- GenerateModel: Create model classes from tables
- GenerateLookups: Generate lookup tables and enums
- DatabaseContext: Generate DbContext classes
View Operations
- CurrentView: Work with database views
- ViewList: Iterate through database views
- View-specific naming conventions (Camel case, lowercase, pluralization)
DTO Operations
- GetDtoColumnNames: Extract DTO property names
- GetDtoColumnCaptions: Generate DTO display names
- MappingDto: Create DTO mapping configurations
- DeclareList: Generate DTO list declarations
Target Frameworks
- .NET Framework 4.8
- .NET 10.0 (Windows)
Installation
Package Manager Console
Install-Package ZeraSystems.CodeNanite.Schema -Version 2.0.0
.NET CLI
dotnet add package ZeraSystems.CodeNanite.Schema --version 2.0.0
PackageReference
<PackageReference Include="ZeraSystems.CodeNanite.Schema" Version="2.0.0" />
Usage
This package is designed to be used within CodeStencil templates for database-driven code generation.
Example: Generate Model from Table
In your CodeStencil template:
<%@ template language="C#" %>
<%@ import namespace="ZeraSystems.CodeNanite.Schema" %>
// Use Schema code nanites
public class <%= CurrentTable() %>
{
<%= GenerateModel() %>
}
Example: Generate DbContext
public class ApplicationDbContext : DbContext
{
<%= GenerateDbSet() %>
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
<%= GenerateFluentConfig() %>
}
}
Dependencies
- ZeraSystems.CodeStencil.Contracts (v2.0.0+)
- ZeraSystems.CodeNanite.Expansion (v2.0.0+)
- Pluralize.NET (v1.0.2+)
- System.ComponentModel.Composition (v4.6.0+ for .NET Framework, v10.0.0+ for .NET 10)
Code Nanite Categories
Columns
- Column name and type extraction
- Column metadata and attributes
- Primary key and foreign key handling
- Input component generation
Tables
- Table iteration and selection
- DbSet generation
- Model class generation
- Entity Framework configuration
Views
- Database view processing
- View-based model generation
- Naming convention transformations
DTOs
- DTO class generation
- Property mapping
- Display name generation
- AutoMapper configuration
Documentation
For complete documentation and examples:
Version History
2.0.0
- Upgraded to .NET 10.0 support
- Maintained .NET Framework 4.8 compatibility
- Updated to CodeStencil.Contracts 2.0.0
- Updated System.ComponentModel.Composition to v10.0.0 for .NET 10
- Converted to SDK-style project format
1.5.x
- Previous stable release for .NET Framework 4.8
License
This package is licensed under the MIT License.
Support
For support and questions:
Copyright
Copyright � 2018-2025 ZERA Systems Inc.