NetSchema.Library
1.0.3
See the version list below for details.
dotnet add package NetSchema.Library --version 1.0.3
NuGet\Install-Package NetSchema.Library -Version 1.0.3
<PackageReference Include="NetSchema.Library" Version="1.0.3" />
<PackageVersion Include="NetSchema.Library" Version="1.0.3" />
<PackageReference Include="NetSchema.Library" />
paket add NetSchema.Library --version 1.0.3
#r "nuget: NetSchema.Library, 1.0.3"
#:package NetSchema.Library@1.0.3
#addin nuget:?package=NetSchema.Library&version=1.0.3
#tool nuget:?package=NetSchema.Library&version=1.0.3
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
Example 1: Auto-Detect Solution Path (Recommended)
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.
?? Links
- Package (after publish): https://www.nuget.org/packages/NetSchema.Library/
- GitHub: https://github.com/emilhuseyn/NetSchema
- Issues: https://github.com/emilhuseyn/NetSchema/issues
- CLI Tool: https://www.nuget.org/packages/NetSchema
?? License
MIT License - see LICENSE
| Product | Versions 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. |
-
net8.0
- Microsoft.EntityFrameworkCore (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version 1.0.3: Final fix - NetSchema.cs file now properly saved and included. Full programmatic API confirmed working.