LinuxCommandLibrary

dotnet-ef

Entity Framework Core database migration tools

TLDR

Add migration

$ dotnet ef migrations add [MigrationName]
copy
Update database
$ dotnet ef database update
copy
List migrations
$ dotnet ef migrations list
copy
Remove last migration
$ dotnet ef migrations remove
copy
Generate SQL script
$ dotnet ef migrations script -o [script.sql]
copy
Rollback to migration
$ dotnet ef database update [MigrationName]
copy
Scaffold DbContext from database
$ dotnet ef dbcontext scaffold "[connection_string]" [Microsoft.EntityFrameworkCore.SqlServer]
copy

SYNOPSIS

dotnet ef command [options]

DESCRIPTION

dotnet ef is the Entity Framework Core CLI tools for database migrations and scaffolding. It enables code-first database development and reverse engineering from existing databases.
The migrations system tracks schema changes in code, generating incremental updates that can be applied to databases. Each migration is a class describing schema modifications.
dbcontext scaffold reverse-engineers a DbContext and entity classes from an existing database, useful for database-first development or migrating legacy databases.

PARAMETERS

COMMAND

Operation: migrations, database, dbcontext.
migrations add NAME
Create new migration.
migrations list
List available migrations.
migrations remove
Remove last migration.
database update [MIGRATION]
Apply migrations to database.
dbcontext scaffold CONN PROVIDER
Generate code from database.
--context NAME
DbContext class to use.
--project PATH
Project containing DbContext.
--help
Display help information.

CAVEATS

Requires Microsoft.EntityFrameworkCore.Tools package. EF Core version must match tooling. Large databases may scaffold slowly. Some database features may not scaffold perfectly.

HISTORY

dotnet ef is part of Entity Framework Core, Microsoft's modern ORM for .NET. EF Core was released with .NET Core in 2016 as a cross-platform rewrite of Entity Framework.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community