Abstract
Managing inventory is a common challenge for small businesses, including event rental companies. In this article, we’ll build a simple, beginner-friendly inventory management feature using ASP.NET Core MVC and Entity Framework Core. This example can be applied to many business types, including party rental services, equipment lenders, or local service providers.
Introduction
Inventory tracking is essential for any service-based business that rents, lends, or schedules equipment. In this walkthrough, we will:
Create an ASP.NET Core MVC project
Define a database model for rental items
Build CRUD operations for managing inventory
Use Entity Framework Core Migrations
Display items using a simple UI
This is a practical starting point for building a full rental management platform.
Project Setup
1. Create a New ASP.NET Core MVC Project
Use the .NET CLI:
dotnet new mvc -n RentalInventoryDemo
cd RentalInventoryDemo
Install Entity Framework Core packages:
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
dotnet add package Microsoft.EntityFrameworkCore.Tools
Creating the Data Model
2. Define the Inventory Item Model
Create a new folder named Models and add InventoryItem.cs.
using System.ComponentModel.DataAnnotations;
namespace RentalInventoryDemo.Models
{
public class InventoryItem
{
public int Id { get; set; }
[Required]
public string ItemName { get; set; }
[Range(0, int.MaxValue)]
public int QuantityAvailable { get; set; }
public string Category { get; set; }
}
}
Configuring the Database Context
3. Add ApplicationDbContext
Create a Data folder → add ApplicationDbContext.cs.
using Microsoft.EntityFrameworkCore;
using RentalInventoryDemo.Models;
namespace RentalInventoryDemo.Data
{
public class ApplicationDbContext : DbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options) { }
public DbSet<InventoryItem> InventoryItems { get; set; }
}
}
Register it in Program.cs
Add:
builder.Services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));

Join the conversation! Your thoughts help the community grow.