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.