Language Notice: View in Arabic (العربية) |
This C# tool automatically generates a complete 3-tier architecture solution based on your SQL Server database schema. It creates four projects:
- DTO (Data Transfer Objects)
- DAL (Data Access Layer)
- BLL (Business Logic Layer)
- ConsoleApp (Presentation Layer)
The generated solution includes complete CRUD operations for all tables and a console-based interface for database interaction.
- 🚀 Automatic generation of 3-tier architecture projects
- 🔍 Reads SQL Server database schema (tables, columns, PKs, FKs)
- 📦 Creates DTO classes for all database tables
- 💾 Generates repository pattern implementation in DAL
- 🧠 Creates business logic layer with placeholder methods
- 💻 Builds console application for database interaction
- 🔄 Full CRUD operations for all database tables
- 📂 Generates solution file and project references
- ⚙️ Automatic App.config with connection string
- .NET Framework 4.8
- SQL Server instance
- Visual Studio 2019 or newer (to open generated solution)
- Clone the repository:
git clone https://github.com/MohmdAliMohmd/3-Tier-Architecture-Solution-Generator.git
- Open the solution in Visual Studio
- Build the solution
- Run the compiled executable
- Provide your SQL Server connection details:
- Server name
- Database name
- Authentication method (Windows or SQL Server)
- Credentials (if using SQL Server authentication)
- Specify the output path for the generated solution
- The tool will generate the complete solution structure
- Open the generated solution in Visual Studio
- Add project references:
- ConsoleApp → BLL
- BLL → DAL
- DAL → DTO
- Verify the connection string in
ConsoleApp/App.config
GeneratedSolution/
├── BLL/
│ ├── [TableName]Service.cs
│ └── BLL.csproj
├── DAL/
│ ├── [TableName]Repository.cs
│ └── DAL.csproj
├── DTO/
│ ├── [TableName]DTO.cs
│ └── DTO.csproj
├── ConsoleApp/
│ ├── App.config
│ ├── Program.cs
│ └── ConsoleApp.csproj
└── DatabaseSolution.sln
- Creates
[TableName]DTO
classes with properties mapping to database columns - Handles nullability based on database schema
- Example:
public class CustomerDTO { public int CustomerID { get; set; } public string Name { get; set; } public string Email { get; set; } public DateTime? RegistrationDate { get; set; } }
- Creates repository classes with complete CRUD operations:
GetAll[TableName]s()
Get[TableName]ById()
Add[TableName]()
Update[TableName]()
Delete[TableName]()
- Uses ADO.NET for database access
- Handles parameterized queries and null values
- Creates service classes that act as intermediaries
- Contains business logic placeholders for validation
- Example:
public void AddCustomer(CustomerDTO item) { // Add validation and business logic here _repository.AddCustomer(item); }
- Dynamic menu system for all tables
- Complete CRUD interface:
- List all records
- View record details
- Add new records
- Update existing records
- Delete records
- Automatic data type handling
- Tabular data display
- Currently supports SQL Server only
- Assumes integer PKs are identity columns
- Console app CRUD operations need implementation
- Limited error handling in generated code
- No support for stored procedures
- Complex relationships may require manual adjustments
Contributions are welcome! Please fork the repository and create a pull request with your improvements.
This project is licensed under the MIT License - see the LICENSE file for details.
- The generated solution targets .NET Framework 4.8
- You may need to adjust null handling for specific data types
- Business logic layer contains placeholders for custom validation
- Console application provides a starting point for UI development
For any questions or issues, please open an issue on GitHub.