GeneratorCode هو تطبيق سطح مكتب مبني بـ .NET 7 Windows Forms لتوليد مشاريع C# كاملة من قواعد البيانات أو من تصميم نماذج المجال. يدعم وضعين أساسيين: Database First (من قاعدة بيانات موجودة) و Code First (تصميم الكيانات وتوليد مشروع EF Core مع إدارة الترحيلات). يوفر واجهة رسومية (GUI) وواجهة سطر أوامر (CLI).
| الوضع | الوصف |
|---|---|
| Database First | الاتصال بقاعدة بيانات موجودة، اكتشاف الجداول والأعمدة والمفاتيح، ثم توليد مشروع كامل |
| Code First | تصميم نموذج المجال (كيانات، خصائص، علاقات) عبر مصمم الكيانات، ثم توليد مشروع EF Core مع إدارة الترحيلات |
| النمط | الحالة |
|---|---|
| Clean Architecture | مكتمل |
| Simple Architecture | مكتمل |
| Layered Architecture | قيد التطوير |
| CQRS Pattern | قيد التطوير |
| Domain-Driven Design (DDD) | قيد التطوير |
| Microservices Architecture | قيد التطوير |
- SQL Server - دعم كامل (جداول، أعمدة، مفاتيح، فهارس، triggers)
- PostgreSQL - دعم كامل
- MySQL / MariaDB - دعم كامل
- Oracle - دعم كامل
- SQLite - دعم كامل
- Entities / Domain Models - نماذج المجال
- DTOs - كائنات نقل البيانات
- Repositories - مستودعات البيانات (مع Generic Repository)
- Services - طبقة الخدمات
- Controllers - وحدات التحكم (ASP.NET Core API)
- Validators - التحقق من البيانات (FluentValidation)
- Mappings - AutoMapper Profiles
- Unit Tests - اختبارات الوحدة
- Integration Tests - اختبارات التكامل
- Dependency Injection - تسجيل الخدمات (Microsoft DI / Autofac)
- ASP.NET Core Views - صفحات Razor
- TypeScript Models - نماذج TypeScript
- ملف الحل
.sln - ملفات المشاريع
.csprojمع حزم NuGet Program.cs/Startup.csappsettings.json.gitignoreREADME.md
| الشاشة | الوظيفة |
|---|---|
| شاشة الاتصال | اختيار نوع قاعدة البيانات، إدخال بيانات الاتصال، اختبار الاتصال، تحميل قواعد البيانات المتاحة، حفظ بيانات الاتصال مشفرة |
| شاشة الجداول | عرض الجداول والأعمدة، اختيار نمط العمارة واللغة، تحديد المكونات والطبقات المراد توليدها، خيارات DI/Async/Tests/Swagger/CRUD |
| مصمم الكيانات | تصميم نموذج المجال: إضافة/حذف/تعديل كيانات وخصائصها وعلاقاتها، حفظ/تحميل/تصدير/استيراد JSON، معاينة كود C# |
| مدير الترحيلات | توليد كود EF Core، إضافة ترحيل، تحديث قاعدة البيانات، التراجع، توليد سكريبت SQL، إزالة آخر ترحيل |
| شاشة المعاينة | عرض الكود المولد مع تلوين بناء الجملة، نسخ إلى الحافظة، حفظ كملف |
| شاشة التقدم | عرض تقدم عملية التوليد مع سجل تفصيلي وشريط تقدم |
| شاشة الإعدادات | مساحة الأسماء الافتراضية، مسار الحفظ، إعدادات قاعدة البيانات الافتراضية (مشفرة)، تصدير/استيراد الإعدادات JSON |
| عارض السجلات | عرض وتصفية السجلات حسب المستوى/التاريخ/المصدر/البحث، تصدير JSON/CSV/TXT |
- C#
- ASP.NET Web Forms
- ASP.NET MVC
- ASP.NET Core
- TypeScript
- .NET 7.0 أو أحدث
- Windows OS (Windows Forms)
- قاعدة بيانات واحدة على الأقل (SQL Server / MySQL / PostgreSQL / Oracle / SQLite)
git clone https://github.com/AbdulqaderMaofaa/GeneratorCode.git
cd GeneratorCode
dotnet build
dotnet run- اختر نوع قاعدة البيانات وأدخل بيانات الاتصال
- اختبر الاتصال واختر قاعدة البيانات
- اضغط "Connect" لفتح شاشة الجداول
- اختر نمط العمارة واللغة والمكونات المطلوبة
- حدد الجداول المراد توليد الكود لها
- اضغط "Generate" لبدء التوليد
- من شاشة الاتصال اختر "Entity Designer"
- صمم الكيانات والخصائص والعلاقات
- احفظ النموذج أو صدّره كـ JSON
- اضغط "Generate" لفتح مدير الترحيلات
- أنشئ المشروع وأضف الترحيلات وحدّث قاعدة البيانات
GeneratorCode.exe --server localhost --database MyDatabase --output C:\Outputالمعاملات:
| المعامل | الوصف | مطلوب |
|---|---|---|
--server |
اسم السيرفر | نعم |
--database |
اسم قاعدة البيانات | نعم |
--output |
مسار حفظ الملفات | نعم |
--db-type |
نوع قاعدة البيانات (SqlServer, MySQL, PostgreSQL) | لا |
--namespace |
مساحة الأسماء | لا |
--pattern |
نمط العمارة (CleanArchitecture, Simple, CQRS, DDD, etc.) | لا |
--enable-di |
تفعيل Dependency Injection | لا |
--async |
توليد عمليات غير متزامنة | لا |
--tests |
توليد اختبارات وحدة | لا |
# Clean Architecture مع DI و Async
GeneratorCode.exe --server localhost --database Northwind --pattern CleanArchitecture --namespace NorthwindApp --output C:\GeneratedCode --enable-di true --async true
# MySQL مع CQRS واختبارات
GeneratorCode.exe --server localhost --database ShopDB --db-type MySQL --pattern CQRS --namespace ShopApp --output C:\ShopCode --tests trueGeneratedProject/
├── src/
│ ├── ProjectName.Domain/ # الكيانات، Value Objects، واجهات المستودعات
│ ├── ProjectName.Application/ # DTOs، خدمات التطبيق، Validators، Mappings
│ ├── ProjectName.Infrastructure/ # تنفيذ المستودعات، DbContext، الإعدادات
│ └── ProjectName.API/ # Controllers، Middleware، Program.cs، Swagger
├── tests/
│ ├── ProjectName.UnitTests/ # اختبارات الوحدة
│ └── ProjectName.IntegrationTests/ # اختبارات التكامل
├── ProjectName.sln
├── appsettings.json
├── .gitignore
└── README.md
GeneratorCode/
├── GeneratorCode.sln
└── GeneratorCode/
├── GeneratorCode.csproj
├── Program.cs
├── CLI/
│ └── CommandLineInterface.cs # معالجة سطر الأوامر
├── Core/
│ ├── ArchitecturePatterns/ # أنماط العمارة (Clean, Simple, Layered, CQRS, DDD, Microservices)
│ ├── CodeFirst/ # EfCoreCodeFirstGenerator، TypeMappingService
│ ├── CodeGenerators/ # مولدات ASP.NET Core Views و TypeScript
│ ├── DatabaseProviders/ # موفرو قواعد البيانات (SqlServer, MySQL, PostgreSql, SQLite, Oracle)
│ ├── DependencyInjection/ # DIIntegrationService، PackagesGenerator
│ ├── DomainModel/ # DomainEntity، DomainProperty، DomainRelation
│ ├── Factories/ # مصانع أنماط العمارة وموفري قواعد البيانات
│ ├── Helpers/ # ConnectionStringBuilder، PasswordEncryption، ProcessRunner
│ ├── Interfaces/ # IDatabaseProvider، IArchitecturePattern، IMigrationService
│ ├── Logging/ # LoggerFactory، ExceptionMiddleware
│ ├── Models/ # CodeGenerationContext، TableInfo، ColumnInfo
│ ├── Services/ # CodeGenerationService، DomainModelService، EfCoreMigrationService
│ └── TemplateEngine/ # محرك القوالب
└── GeneratorCode/
├── Forms/ # شاشات التطبيق (Connection, Tables, Preview, Settings, EntityDesigner, etc.)
└── Helpers/ # AppTheme، DatabaseHelper، LogViewerHelper
| الحزمة | الاستخدام |
|---|---|
| MaterialSkin.2 | واجهة مستخدم حديثة (Material Design) |
| Microsoft.Data.SqlClient | الاتصال بـ SQL Server |
| Npgsql | الاتصال بـ PostgreSQL |
| MySql.Data | الاتصال بـ MySQL |
| Microsoft.Data.Sqlite | الاتصال بـ SQLite |
| Oracle.ManagedDataAccess.Core | الاتصال بـ Oracle |
| System.CommandLine | واجهة سطر الأوامر |
| System.Security.Cryptography.ProtectedData | تشفير كلمات المرور |
- المستويات: Debug, Info, Warning, Error
- التنسيق: JSON منظم مع Correlation ID
- واجهة العرض: تصفية حسب المستوى/التاريخ/المصدر/النص
- التصدير: JSON, CSV, TXT
- تفاصيل الأخطاء: عرض Stack Trace و Inner Exceptions و بيانات إضافية
- تشفير كلمات المرور المحفوظة باستخدام DPAPI
- عدم تخزين بيانات الاتصال بنص واضح
- تصدير/استيراد الإعدادات بدون كلمات المرور
- Fork المشروع
- إنشاء branch للميزة (
git checkout -b feature/AmazingFeature) - Commit التغييرات (
git commit -m 'Add some AmazingFeature') - Push للـ branch (
git push origin feature/AmazingFeature) - فتح Pull Request
هذا المشروع مرخص تحت MIT License
- عبدالقادر موفعة - GitHub
- Issues: GitHub Issues
- Email: maofaacom@gmail.com
GeneratorCode is a .NET 7 Windows Forms desktop application that generates complete C# projects from existing databases or from hand-designed domain models. It supports two primary modes: Database First (reverse-engineer an existing database) and Code First (design entities in a visual designer and generate an EF Core project with migration management). Both a GUI and a CLI are provided.
| Mode | Description |
|---|---|
| Database First | Connect to an existing database, discover tables/columns/keys, and generate a full project |
| Code First | Design a domain model (entities, properties, relations) in the Entity Designer, then generate an EF Core project with migration management |
| Pattern | Status |
|---|---|
| Clean Architecture | Complete |
| Simple Architecture | Complete |
| Layered Architecture | In Development |
| CQRS Pattern | In Development |
| Domain-Driven Design (DDD) | In Development |
| Microservices Architecture | In Development |
- SQL Server - Full support (tables, columns, keys, indexes, triggers)
- PostgreSQL - Full support
- MySQL / MariaDB - Full support
- Oracle - Full support
- SQLite - Full support
- Entities / Domain Models
- DTOs - Data Transfer Objects
- Repositories - with Generic Repository pattern
- Services - Service layer
- Controllers - ASP.NET Core API controllers
- Validators - FluentValidation
- Mappings - AutoMapper Profiles
- Unit Tests
- Integration Tests
- Dependency Injection - Service registration (Microsoft DI / Autofac)
- ASP.NET Core Views - Razor pages
- TypeScript Models
.slnsolution file.csprojproject files with NuGet packagesProgram.cs/Startup.csappsettings.json.gitignoreREADME.md
| Screen | Purpose |
|---|---|
| Connection | Select database type, enter credentials, test connection, load available databases, save encrypted credentials |
| Tables | Browse tables and columns, select architecture pattern and language, choose components and layers to generate, DI/Async/Tests/Swagger/CRUD options |
| Entity Designer | Design domain model: add/remove/edit entities, properties (type, required, PK, identity, max length, default, description), and relations (target, type, FK, delete behavior, navigation); save/load/export/import JSON; preview C# code |
| Migration Manager | Generate EF Core code, add migration, update database, rollback, generate SQL script, remove last migration, list migrations |
| Preview | View generated code with syntax highlighting; copy to clipboard or save as file |
| Progress | Real-time generation progress with detailed log and progress bar |
| Settings | Default namespace, output path, default database credentials (encrypted), export/import settings as JSON |
| Log Viewer | View and filter logs by level/date/source/search; export to JSON/CSV/TXT |
- C#
- ASP.NET Web Forms
- ASP.NET MVC
- ASP.NET Core
- TypeScript
- .NET 7.0 or later
- Windows OS (Windows Forms)
- At least one database (SQL Server / MySQL / PostgreSQL / Oracle / SQLite)
git clone https://github.com/AbdulqaderMaofaa/GeneratorCode.git
cd GeneratorCode
dotnet build
dotnet run- Select the database type and enter connection credentials
- Test the connection and select a database
- Click "Connect" to open the Tables screen
- Choose architecture pattern, language, and desired components
- Select the tables to generate code for
- Click "Generate" to start generation
- From the Connection screen, choose "Entity Designer"
- Design entities, properties, and relations
- Save the model or export it as JSON
- Click "Generate" to open the Migration Manager
- Generate the project, add migrations, and update the database
GeneratorCode.exe --server localhost --database MyDatabase --output C:\OutputParameters:
| Parameter | Description | Required |
|---|---|---|
--server |
Server name | Yes |
--database |
Database name | Yes |
--output |
Output path | Yes |
--db-type |
Database type (SqlServer, MySQL, PostgreSQL) | No |
--namespace |
Namespace for generated code | No |
--pattern |
Architecture pattern (CleanArchitecture, Simple, CQRS, DDD, etc.) | No |
--enable-di |
Enable Dependency Injection | No |
--async |
Generate async operations | No |
--tests |
Generate unit tests | No |
# Clean Architecture with DI and Async
GeneratorCode.exe --server localhost --database Northwind --pattern CleanArchitecture --namespace NorthwindApp --output C:\GeneratedCode --enable-di true --async true
# MySQL with CQRS and Tests
GeneratorCode.exe --server localhost --database ShopDB --db-type MySQL --pattern CQRS --namespace ShopApp --output C:\ShopCode --tests trueGeneratedProject/
├── src/
│ ├── ProjectName.Domain/ # Entities, Value Objects, Repository interfaces
│ ├── ProjectName.Application/ # DTOs, Application services, Validators, Mappings
│ ├── ProjectName.Infrastructure/ # Repository implementations, DbContext, Configuration
│ └── ProjectName.API/ # Controllers, Middleware, Program.cs, Swagger
├── tests/
│ ├── ProjectName.UnitTests/
│ └── ProjectName.IntegrationTests/
├── ProjectName.sln
├── appsettings.json
├── .gitignore
└── README.md
GeneratorCode/
├── GeneratorCode.sln
└── GeneratorCode/
├── GeneratorCode.csproj
├── Program.cs
├── CLI/
│ └── CommandLineInterface.cs # CLI argument handling
├── Core/
│ ├── ArchitecturePatterns/ # Clean, Simple, Layered, CQRS, DDD, Microservices
│ ├── CodeFirst/ # EfCoreCodeFirstGenerator, TypeMappingService
│ ├── CodeGenerators/ # ASP.NET Core Views, TypeScript generators
│ ├── DatabaseProviders/ # SqlServer, MySQL, PostgreSql, SQLite, Oracle
│ ├── DependencyInjection/ # DIIntegrationService, PackagesGenerator
│ ├── DomainModel/ # DomainEntity, DomainProperty, DomainRelation
│ ├── Factories/ # ArchitecturePatternFactory, DatabaseProviderFactory
│ ├── Helpers/ # ConnectionStringBuilder, PasswordEncryption, ProcessRunner
│ ├── Interfaces/ # IDatabaseProvider, IArchitecturePattern, IMigrationService
│ ├── Logging/ # LoggerFactory, ExceptionMiddleware
│ ├── Models/ # CodeGenerationContext, TableInfo, ColumnInfo
│ ├── Services/ # CodeGenerationService, DomainModelService, EfCoreMigrationService
│ └── TemplateEngine/ # Template engine for code generation
└── GeneratorCode/
├── Forms/ # UI forms (Connection, Tables, Preview, Settings, EntityDesigner, etc.)
└── Helpers/ # AppTheme, DatabaseHelper, LogViewerHelper
| Package | Purpose |
|---|---|
| MaterialSkin.2 | Material Design UI |
| Microsoft.Data.SqlClient | SQL Server connectivity |
| Npgsql | PostgreSQL connectivity |
| MySql.Data | MySQL connectivity |
| Microsoft.Data.Sqlite | SQLite connectivity |
| Oracle.ManagedDataAccess.Core | Oracle connectivity |
| System.CommandLine | CLI interface |
| System.Security.Cryptography.ProtectedData | Password encryption |
- Levels: Debug, Info, Warning, Error
- Format: Structured JSON with Correlation ID
- Viewer: Filter by level/date/source/text
- Export: JSON, CSV, TXT
- Error Details: Stack trace, inner exceptions, additional data
- Saved passwords encrypted with DPAPI
- No plaintext credential storage
- Settings export/import excludes passwords
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License
- Abdulqader Maofaa - GitHub
- Issues: GitHub Issues
- Email: maofaacom@gmail.com