AP.NET Entity Framework (EF)


This project uses AP.NET Entity Framework (EF), which supports two primary approaches for working with databases: Code/Database-First.

EF Core Code-First Approach
This approach defines your database schema using C# classes. For example,
   public class Product {
     public int Id { get; set; }
     public string Name { get; set; }
     public decimal Price { get; set; } }
The database is generated based on these classes by entering the following two commands in Package Manager Console:
  1. and
  2. .
It is ideal when starting a new project where the database does not yet exist.

EF Core Database-First Approach
This approach starts with an existing database, and EF generates the data model (classes) based on the database schema. Use the or command to generate models. For example,
    "YourConnectionString"
    -OutputDir Models
Best suited for projects where the database already exists and you want to integrate it into your application.

Choosing between Code-First and Database-First Approaches



      “I’m paranoid about everything in my life.    
      Even at home on my stationary bike,    
      I’ve got a rearview mirror.”    
      — Richard Lewis