is a powerful code-generation library for .NET 8 that automates the scaffolding of backend components like models, services, controllers, and more—based on a flexible folder configuration.
$ dotnet add package WasmAI.AutoGeneratorWasmAI.AutoGenerator is a powerful code-generation library for .NET 8 that automates the scaffolding of backend components like models, services, controllers, and more—based on a flexible folder configuration.
⚙️ Automatic Generation of Backend Layers:
🗂️ Dynamic Folder and File Generation:
Uses folderStructure.json to generate nested folders and files.
🏗️ Architecture Pattern Support:
Built-in templates: Country, Plug, Share, Builder, Service, and Scope.
🛠️ Customizable & Modular: Easily adapt to any backend architecture style.
🔁 Service Lifetime Support: Scoped, singleton, and transient services supported.
🔔 Built-in Notification Provider: Supports Email, SMS, Push, and In-App notifications.
┌─────────────┐ ┌────────────────────┐ ┌────────────────┐
│ Models │──────▶│ Marker Interfaces │──────▶│ AutoGenerator │
└─────────────┘ └────────────────────┘ └──────┬──────────┘
▼
┌────────────┬─────────────┬──────────────┬─────────────┬──────────────┐
│ DTOs │ Repositories│ Services │ Controllers │ Validators │
└────────────┴─────────────┴──────────────┴─────────────┴──────────────┘
dotnet add package WasmAI.AutoGenerator --version 1.1.0
👉 After installation, add the necessary namespace:
using AutoGenerator.ApiFolder;
folderStructure.json)Here's an example:
{
"Controllers": [ "Api", "Auth", "Admin" ],
"Repositories": [ "Base", "Builder", "Share" ],
"Services": [ "Email", "Logging" ],
"DyModels": [
{
"VM": [],
"Dto": {
"Build": [ "Request", "Response", "ResponseFilter" ],
"Share": [ "Request", "Response", "ResponseFilter" ]
},
"Dso": [ "Request", "Response", "ResponseFilter" ]
}
],
"Config": [ "Mappers", "Scopes", "Singletons", "Transients" ],
"Models": [],
"Builders": [ "Db" ],
"Helper": [],
"Data": [],
"Enums": [],
"Validators": [ "Conditions" ],
"Schedulers": []
}
using AutoGenerator.ApiFolder;
using System;
class Program
{
static void Main(string[] args)
{
string projectPath = "path_to_your_project";
ApiFolderGenerator.Build(projectPath);
Console.WriteLine("✅ All folders have been created successfully!");
}
}
dotnet run generate
This command reads the folderStructure.json and creates all required folders and files instantly.
DataContext and CategoryModel with ITModel and ITAutoDbContextDataContextFirst, you need to make sure that DataContext inherits from AutoIdentityDataContext and implements ITAutoDbContext. This allows you to manage identity operations and database access in a simple and automated way.
public class DataContext : AutoIdentityDataContext<ApplicationUser, IdentityRole, string>, ITAutoDbContext
{
// Add properties like DbSet for your models
public DbSet<CategoryModel> Categories { get; set; }
public DataContext(DbContextOptions<DataContext> options) : base(options)
{
}
// You can add any custom functions for DbContext here
}
DataContext inherits from AutoIdentityDataContext<ApplicationUser, IdentityRole, string> because you need to work with identity management using ApplicationUser and IdentityRole.ITAutoDbContext ensures that the DataContext can handle automatic operations.DbSet<CategoryModel> is an example of adding a model to DataContext so it can be interacted with in the database.CategoryModel and Implement ITModelNow, you need to implement the ITModel interface in your models like CategoryModel to take advantage of automatic operations.
public class CategoryModel : ITModel
{
[Key]
public string? Id { get; set; } = $"catm_{Guid.NewGuid():N}"; // Automatically generates a unique value
[Required]
[ToTranslation] // Mark to ensure the field is translated automatically
public string? Name { get; set; }
[ToTranslation] // Mark to ensure the field is translated automatically
public string? Description { get; set; }
}
CategoryModel class implements ITModel, which means it includes an Id property that gets automatically generated using Guid.NewGuid().Name and Description properties have the [ToTranslation] attribute to indicate that they should be translated automatically.Here’s how to configure it in your project:
builder.Services
. AddAutoBuilderApiCore<DataContext,ApplicationUser>(new()
{
Arags = args,
NameRootApi = "V1",
IsMapper = true,
Assembly = Assembly.GetExecutingAssembly(),
DbConnectionString = builder.Configuration.GetConnectionString("DefaultConnection"),
ProjectPath= "folderStructure.json"
})
.AddAutoValidator()
.AddAutoConfigScheduler()
.AddAutoNotifier(new()
{
MailConfiguration = new MailConfig()
{
SmtpUsername = "user@gmail.com",
SmtpPassword = "your_smtp_password", // 🔒 Secure this!
SmtpHost = "smtp.gmail.com",
SmtpPort = 587,
FromEmail = "user@gmail.com",
NameApp = "app"
},
// sms
// push web any platforms
});
WasmAI.AutoGenerator supercharges your .NET development by reducing boilerplate and enforcing clean, modular architecture. Whether you're building an admin panel, a complex API, or a service-oriented backend—this tool lets you build your project architecture in seconds with:
dotnet run generate
dotnet run generate /bpr
Start building smarter. 💡