A comprehensive ASP.NET Core MVC e-commerce application built with .NET 10, Entity Framework Core, and ASP.NET Identity for user authentication and management.
This is a full-featured e-commerce web application that allows users to browse products, manage shopping carts, place orders, and manage their profiles. The application implements a hierarchical category system, user authentication, and order management.
- Framework: ASP.NET Core with .NET 10
- Database: SQL Server with Entity Framework Core
- Authentication: ASP.NET Identity
- Pattern: MVC (Model-View-Controller)
- Session Management: ASP.NET Core Session
MVC_Project/
βββ Entities/ # Core domain models
β βββ AppUser.cs # Extended Identity user
β βββ Product.cs # Product catalog
β βββ Category.cs # Category hierarchy
β βββ Order.cs # Customer orders
β βββ OrderItem.cs # Order line items
β βββ Address.cs # Shipping addresses
βββ Controllers/ # MVC controllers
β βββ CatalogController.cs # Product browsing & search
β βββ AccountController.cs # Authentication & registration
β βββ ProfileController.cs # User profile management
β βββ HomeController.cs # Home page
βββ Views/ # Razor views
βββ Models/ViewModels/ # View model objects
βββ Infrastructure/
β βββ Data/
β β βββ AppDbContext.cs # EF Core database context
β βββ Configurations/ # EF Core entity configurations
βββ Repo/ # Data access layer
β βββ UnitOfWork.cs # Unit of Work pattern
β βββ EntityRepo.cs # Generic repository
β βββ ProductRepo.cs # Product-specific queries
β βββ CategoryRepo.cs # Category-specific queries
β βββ ...
βββ Migrations/ # Database migrations
Extended ASP.NET Identity user with:
- Full name storage
- Multiple shipping addresses
- Order history
E-commerce product representation:
- Name and SKU (Stock Keeping Unit)
- Pricing with decimal precision
- Stock quantity tracking
- Active/inactive status
- Category association
- Creation timestamp
Hierarchical category system:
- Parent-child category relationships
- Supports unlimited nesting levels
- Associated products
Customer order management:
- Order number and status tracking
- Associated user and shipping address
- Order date and total amount
- Collection of order items
- Decimal precision for amounts
Individual line items in orders:
- Product and order references
- Unit price and quantity
- Computed line total
Shipping address management:
- Complete address fields (country, city, street, zip)
- Multiple addresses per user
- Default address flag
- Associated orders
- Browse products with pagination
- Search by product name or SKU
- Sort by name, price, or popularity
- Filter by category with hierarchical support
- Advanced filtering with descendant categories
- User registration with email verification
- Secure login/logout
- Role-based access control (User roles)
- Password security
- View and edit profile information
- Manage multiple shipping addresses
- Set default address
- Order history tracking
- Session-based cart storage
- Add/remove products
- Quantity adjustment
- Create orders from cart
- Order status tracking
- Order history for users
- Order number generation
"DefaultConnection": "Data Source=.;Initial Catalog=MVC_Project;Integrated Security=True;TrustServerCertificate=True"
- SQL Server with local database or network instance support
- Entity Framework Core for ORM
- .NET 10 SDK
- SQL Server (local or remote)
- Visual Studio 2026 (or compatible IDE)
- Clone the repository
git clone https://github.com/abdallagaber/MVC_Project.git
- Navigate to project directory
cd MVC_Project
-
Update database connection
- Edit
appsettings.json - Update
DefaultConnectionif needed
- Edit
-
Apply database migrations
dotnet ef database update
- Run the application
dotnet run
- Access the application
- Open browser to
https://localhost:5001(or configured port) - Default route: Catalog Index
- Open browser to
Microsoft.EntityFrameworkCoreMicrosoft.EntityFrameworkCore.SqlServerMicrosoft.AspNetCore.Identity.EntityFrameworkCoreMicrosoft.AspNetCore.Session
IUnitOfWorkinterface for transaction management- Provides access to all repositories
- Ensures data consistency across operations
- Generic
EntityRepo<T>base repository - Specialized repositories for complex queries:
ProductRepo: Product-specific queries and active product filteringCategoryRepo: Hierarchical category queriesAddressRepo: User address management
- Constructor injection for services
- Scoped lifetime for repositories and DbContext
- Configured in
Program.cs
- ASP.NET Identity for authentication
- Password hashing and validation
- Entity Framework Core parameterized queries (SQL injection protection)
- Authorization attributes on protected controllers
- Session-based state management
// Database context
builder.Services.AddDbContext<AppDbContext>(options =>
{
options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection"));
});
// Unit of Work
builder.Services.AddScoped<IUnitOfWork, UnitOfWork>();
// Identity
builder.Services.AddIdentity<AppUser, IdentityRole>(options =>
{
options.User.RequireUniqueEmail = true;
})
.AddEntityFrameworkStores<AppDbContext>();
// Sessions
builder.Services.AddSession();-
Catalog Browsing
- User accesses Catalog/Index
- CatalogController queries products through UnitOfWork
- Results paginated and displayed with filters/sorting
-
User Registration/Login
- User submits registration form
- AccountController uses UserManager for identity operations
- User assigned "User" role
-
Order Creation
- Cart data retrieved from session
- OrderController creates Order and OrderItems
- Order associated with user and shipping address
- UnitOfWork ensures data consistency
The project uses Entity Framework Core Code-First approach with migrations:
- Located in
Migrations/folder - Initial migration:
20260310204100_InitialCreate.cs - Run migrations with:
dotnet ef database update
Add new entity:
- Create entity class in
Entities/ - Add DbSet to
AppDbContext - Add configuration if needed in
Configurations/ - Create migration:
dotnet ef migrations add MigrationName - Update database:
dotnet ef database update
Add new repository:
- Create repository class extending
EntityRepo<T> - Add interface to
IUnitOfWork - Register in
UnitOfWorkimplementation - Inject through DI container
Logging configuration in appsettings.json:
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}- Repository URL: https://github.com/abdallagaber/MVC_Project
- Branch: master
This project is developed as an educational exercise to demonstrate:
- ASP.NET Core MVC fundamentals
- Entity Framework Core with SQL Server
- ASP.NET Identity integration
- Repository and Unit of Work patterns
- Hierarchical data management
- E-commerce domain modeling
- Session-based state management
This is an educational project. For improvements or bug fixes, please create issues or pull requests on the GitHub repository.