Installation
1. Open a terminal and navigate into the project's folder2. Use the following .NET Core CLI command from the operating system's command line to install or update the EF Core SQL Server provider
Global EF installation
dotnet ef must be installed as a global or local tool. Most developers will install dotnet ef as a global tool with the following command:https://docs.microsoft.com/en-us/ef/core/get-started/?tabs=netcore-cli
=============
Project
for MS SQLdotnet add package Microsoft.EntityFrameworkCore.SqlServer
or for SQLite
dotnet add package Microsoft.EntityFrameworkCore.Sqlite
modifier
3. Install tools to carry out EF Core-related tasks in your project, like creating and applying database migrations, or creating an EF Core model based on an existing database
dotnet add package Microsoft.EntityFrameworkCore.Design
dotnet add package Microsoft.EntityFrameworkCore.Tools
-v // version
-v 2.2.0
-v 2.2.0
For ASP.NET Core apps, this package is included automatically. Database provider design-time packages such as Microsoft.EntityFrameworkCore.SqlServer.Design are no longer required or supported from EF Core 2.0 and later, but aren't automatically removed when upgrading the other packages
4. To get the Package Manager Console tools for EF Core, install
or install packages via NuGet
=============
Add Migrations
After you've defined your initial model, it's time to create the database. To add an initial migration, run the following command:Update the database
Next, apply the migration to the database to create the schema.
dotnet ef database update
Remove a migration
Remove a migration
Sometimes you add a migration and realize you need to make additional changes to your EF Core model before applying it. To remove the last migration, use this command. After removing the migration, you can make the additional model changes and add it again.
dotnet ef migrations remove
Revert a migration
If you already applied a migration (or several migrations) to the database but need to revert it, you can use the same command to apply migrations, but specify the name of the migration you want to roll back to.
dotnet ef database update LastGoodMigration
=============
=============
Commands
dotnet ef migrations add
dotnet ef migrations list
dotnet ef migrations script
dotnet ef dbcontext info
dotnet ef dbcontext scaffold
dotnet ef database drop
dotnet ef database update
dotnet ef migrations list
dotnet ef migrations script
dotnet ef dbcontext info
dotnet ef dbcontext scaffold
dotnet ef database drop
dotnet ef database update