Entity Framework Core Demo - Complete Guide

This comprehensive demo shows the evolution from raw ADO.NET to Entity Framework Core, demonstrating Code-First approach with migrations and CRUD operations.

Overview: ADO.NET vs Entity Framework Core

Aspect ADO.NET (Previous Demo) Entity Framework Core
Database Operations Manual SQL queries LINQ expressions
Connection Management Manual open/close Automatic
Object Mapping Manual mapping Automatic ORM
Schema Management Manual table creation Code-First migrations
Type Safety String-based queries Strongly-typed

Step 1: Package Installation & Setup

Required NuGet Packages

1. Microsoft.EntityFrameworkCore 8.0.0          - Core EF functionality
2. Microsoft.EntityFrameworkCore.Design 8.0.0   - Design-time tools
3. Microsoft.EntityFrameworkCore.SqlServer 8.0.0 - SQL Server provider
4. Microsoft.EntityFrameworkCore.Tools 8.0.0    - Migration tools

Installation Commands

Install-Package Microsoft.EntityFrameworkCore -Version 8.0.0
Install-Package Microsoft.EntityFrameworkCore.Design -Version 8.0.0
Install-Package Microsoft.EntityFrameworkCore.SqlServer -Version 8.0.0
Install-Package Microsoft.EntityFrameworkCore.Tools -Version 8.0.0


Step 2: Entity Classes (POCOs) Analysis

Employee Entity

[Table("Employee")]  // Maps to 'Employee' table instead of 'Emp'
public class Emp
{
    [Column("No")]   // Maps to 'No' column
    [Key]            // Primary key designation
    public int No { get; set; }

    [Column("Name")]
    [StringLength(50)]  // Varchar(50) constraint
    public string Name { get; set; }

    [Column("Address")]
    [StringLength(50)]  // Varchar(50) constraint
    public string Address { get; set; }
}

Key Features: