Table of contents
  1. EntityFramework
    1. CLI
      1. add
      2. create db tables
      3. apply create
      4. revisions
      5. update
      6. Build scafolding




EntityFramework

CLI

add

dotnet add package Microsoft.EntityFrameworkCore.Sqlite;
dotnet add package Microsoft.EntityFrameworkCore.Design;
dotnet tool install --global dotnet-ef;

create db tables

using ContosoPizza.Data;

apply create

dotnet ef database update --context PizzaContext

revisions

dotnet ef migrations add ModelRevisions --context PizzaContext

update

dotnet ef database update --context PizzaContext

Build scafolding

dotnet ef dbcontext scaffold "Data Source=./Promotions/Promotions.db" Microsoft.EntityFrameworkCore.Sqlite --context-dir ./Data --output-dir .\Models
The preceding command:

Scaffolds a DbContext and model classes using the provided connection string.
Specifies the Microsoft.EntityFrameworkCore.Sqlite database provider should be used.
Specifies directories for the resulting DbContext and model classes.