We're creating a simple Employee Management System where you can:
Think of it like a digital employee directory that you can manage through a web browser.
Project Folder
├── Models/ (What data looks like)
├── Views/ (What users see - HTML pages)
├── Controllers/ (What happens when users click buttons)
└── Program.cs (Starting point of the application)
Simple Explanation:
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace _001DemoMVC.Models
{
[Table("Employee")] // This tells the database to create a table called "Employee"
public class Emp
{
[Key] // This makes "No" the primary key (unique identifier)
[Column("No")] // Database column name
public int No { get; set; } // Employee number (auto-generated)
[Column("Name")] // Database column name
[StringLength(50)] // Name cannot be longer than 50 characters
[Required(ErrorMessage = "Name is required")] // Name must be provided
public string Name { get; set; } // Employee name
[Column("Address")] // Database column name
[StringLength(100)] // Address cannot be longer than 100 characters
[Required(ErrorMessage = "Address is required")] // Address must be provided
public string Address { get; set; } // Employee address
}
}