### Verify EF Core tools installation Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/cli/powershell.md Run this command to verify that the tools are correctly installed and accessible. ```powershell Get-Help about_EntityFrameworkCore ``` ```output _/ ---==/ \\ ___ ___ |. \|\ | __|| __| | ) \\\ | _| | _| \_/ | //|\\ |___||_| / \\\/\\ TOPIC about_EntityFrameworkCore SHORT DESCRIPTION Provides information about the Entity Framework Core Package Manager Console Tools. ``` -------------------------------- ### Install Microsoft.EntityFrameworkCore.InMemory using .NET CLI Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/providers/in-memory/index.md Installs the EF Core in-memory database provider package into your project using the .NET CLI. ```dotnetcli dotnet add package Microsoft.EntityFrameworkCore.InMemory ``` -------------------------------- ### Install Microsoft.EntityFrameworkCore.Cosmos with .NET CLI Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/providers/cosmos/index.md Installs the Azure Cosmos DB database provider package for Entity Framework Core using the .NET CLI. ```dotnetcli dotnet add package Microsoft.EntityFrameworkCore.Cosmos ``` -------------------------------- ### Install Microsoft.EntityFrameworkCore.Tools in Package Manager Console Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/get-started/overview/install.md Installs the Package Manager Console tools for EF Core in Visual Studio on Windows. ```powershell Install-Package Microsoft.EntityFrameworkCore.Tools ``` -------------------------------- ### Install SQLite provider using Package Manager Console Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/get-started/overview/first-app.md Installs the Microsoft.EntityFrameworkCore.Sqlite package using the Package Manager Console in Visual Studio. ```powershell Install-Package Microsoft.EntityFrameworkCore.Sqlite ``` -------------------------------- ### Install dotnet-ef global tool via .NET CLI Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/get-started/overview/install.md Installs the `dotnet ef` command globally for running EF Core tools across Windows, Linux, or macOS. Requires the .NET SDK. ```dotnetcli dotnet tool install --global dotnet-ef ``` -------------------------------- ### Install database provider via .NET CLI or Package Manager Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/providers/index.md Installs an EF Core database provider NuGet package into your project using CLI or Visual Studio. ```dotnetcli dotnet add package provider_package_name ``` ```powershell install-package provider_package_name ``` -------------------------------- ### Install Microsoft.EntityFrameworkCore.Tasks via .NET CLI Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/cli/msbuild.md Installs the Microsoft.EntityFrameworkCore.Tasks package into the project. Every project that needs to compile with generated files must reference this package directly because it is not transitive by default. ```dotnetcli dotnet add package Microsoft.EntityFrameworkCore.Tasks ``` -------------------------------- ### Install Microsoft.EntityFrameworkCore.InMemory using Package Manager Console Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/providers/in-memory/index.md Installs the EF Core in-memory database provider package into your project using Visual Studio's Package Manager Console. ```powershell Install-Package Microsoft.EntityFrameworkCore.InMemory ``` -------------------------------- ### Install Microsoft.EntityFrameworkCore.Cosmos with Visual Studio Package Manager Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/providers/cosmos/index.md Installs the Azure Cosmos DB database provider package for Entity Framework Core using the Visual Studio Package Manager Console. ```powershell Install-Package Microsoft.EntityFrameworkCore.Cosmos ``` -------------------------------- ### Create migrations and update database using .NET CLI Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/get-started/overview/first-app.md Installs dotnet-ef and the design package, generates the InitialCreate migration, and applies it to create the SQLite database. ```dotnetcli dotnet tool install --global dotnet-ef dotnet add package Microsoft.EntityFrameworkCore.Design dotnet ef migrations add InitialCreate dotnet ef database update ``` -------------------------------- ### Create a console project using .NET CLI Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/get-started/overview/first-app.md Creates a new .NET console application named EFGetStarted and navigates into the project directory. ```dotnetcli dotnet new console -o EFGetStarted cd EFGetStarted ``` -------------------------------- ### Install dotnet-ef targeting .NET Core 3.1 Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/what-is-new/ef-core-6.0/breaking-changes.md Installs an older version of the dotnet-ef tool to run it without installing the .NET 6 runtime. ```dotnetcli dotnet tool install dotnet-ef --version 3.1.* ``` -------------------------------- ### Build and serve documentation locally on Windows Source: https://github.com/dotnet/entityframework.docs/blob/main/CONTRIBUTING.md Runs DocFX with the default template and local web server. Execute this command from the cloned repository root containing docfx.json to view the site at http://localhost:8080. ```console docfx -t default --serve ``` -------------------------------- ### Install SpatiaLite on Debian, Ubuntu, and macOS Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/providers/sqlite/spatial.md Install native SpatiaLite libraries using APT on Debian/Ubuntu or Homebrew on macOS. ```bash # Debian/Ubuntu apt-get install libsqlite3-mod-spatialite # macOS brew install libspatialite ``` -------------------------------- ### Execute migration bundle with --connection parameter Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/what-is-new/ef-core-6.0/whatsnew.md Passes a target database connection string on the command line to migrate a specific database environment such as production. ```dotnetcli PS C:\local\AllTogetherNow\SixOh> .\efbundle.exe --connection "Data Source=(LocalDb)\MSSQLLocalDB;Database=SixOhProduction" Applying migration '20210903083845_MyMigration'. Applying migration '20210903084526_SecondMigration'. Applying migration '20210903084538_Number3'. Done. PS C:\local\AllTogetherNow\SixOh> ``` -------------------------------- ### Application startup output before model compilation Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/what-is-new/ef-core-9.0/whatsnew.md Demonstrates initial application startup logs showing EF Core actively building the model at runtime. ```output Starting application... >> EF is building the model... Model loaded with 2 entity types. ``` -------------------------------- ### Install SQLite provider using .NET CLI Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/get-started/overview/first-app.md Installs the Microsoft.EntityFrameworkCore.Sqlite package to target SQLite databases using the .NET CLI. ```dotnetcli dotnet add package Microsoft.EntityFrameworkCore.Sqlite ``` -------------------------------- ### Create migrations and update database using Package Manager Console Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/get-started/overview/first-app.md Installs EF Core tools in Visual Studio, scaffolds the InitialCreate migration, and applies it to create the database schema. ```powershell Install-Package Microsoft.EntityFrameworkCore.Tools Add-Migration InitialCreate Update-Database ``` -------------------------------- ### Create and apply a migration using -Add Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/cli/powershell.md Creates a new migration and applies it to the database in a single step using runtime Roslyn compilation. Requires specifying a migration name with the -Migration parameter. ```powershell Update-Database -Migration InitialCreate -Add ``` -------------------------------- ### Apply migrations using efbundle with credentials Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/managing-schemas/migrations/applying.md Executes the migration bundle against a local SQL Server instance using explicit database connection details and credentials. ```powershell .\efbundle.exe --connection 'Data Source=(local)\MSSQLSERVER;Initial Catalog=Blogging;User ID=myUsername;Password={;'$Credential;'here'}' ``` -------------------------------- ### Create and apply a migration in one step using --add Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/cli/dotnet.md Creates a new migration and applies it to the database in a single step using Roslyn compilation at runtime. Supports optional parameters to specify target directory and namespace. ```dotnetcli dotnet ef database update InitialCreate --add dotnet ef database update AddProducts --add --output-dir Migrations/Products --namespace MyApp.Migrations ``` -------------------------------- ### Install Microsoft.EntityFrameworkCore.SqlServer.HierarchyId package Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/providers/sql-server/hierarchyid.md Install the package required to enable HierarchyId functionality in EF Core via the .NET CLI or Visual Studio Package Manager Console. ```dotnetcli dotnet add package Microsoft.EntityFrameworkCore.SqlServer.HierarchyId ``` ```powershell Install-Package Microsoft.EntityFrameworkCore.SqlServer.HierarchyId ``` -------------------------------- ### Create a migration bundle using dotnet ef CLI Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/what-is-new/ef-core-6.0/whatsnew.md Builds a standalone executable containing migrations and the code required to apply them to a database. Requires migrations to already exist in the project. ```dotnetcli PS C:\local\AllTogetherNow\SixOh> dotnet ef migrations bundle Build started... Build succeeded. Building bundle... Done. Migrations Bundle: C:\local\AllTogetherNow\SixOh\efbundle.exe PS C:\local\AllTogetherNow\SixOh> ``` -------------------------------- ### Verify EF Core CLI installation with dotnet ef Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/cli/dotnet.md Runs the dotnet ef command to verify that the CLI tools are installed properly and outputs the active version. ```dotnetcli dotnet ef ``` ```output _/\__ ---==/ \\ ___ ___ |. \|\ | __|| __| | ) \\\ | _| | _| \_/ | //|\\ |___||_| / \\\/\\ Entity Framework Core .NET Command-line Tools 2.1.3-rtm-32065 ``` -------------------------------- ### Create and apply a migration with custom options in .NET CLI Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/managing-schemas/migrations/managing.md Passes migration scaffolding options such as `--output-dir` and `--namespace` when creating and applying a migration in a single step. ```dotnetcli dotnet ef database update AddProducts --add --output-dir Migrations/Products --namespace MyApp.Migrations ``` -------------------------------- ### Update installed template packages using dotnet new update Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/managing-schemas/scaffolding/templates.md Updates installed dotnet template packages to their latest versions before adding default templates to a new project. ```dotnetcli dotnet new update ``` -------------------------------- ### Apply migrations using efbundle.exe Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/managing-schemas/migrations/applying.md Executes the bundle to apply unapplied migrations to the target database. ```dotnetcli PS C:\local\AllTogetherNow\SixOh> .\efbundle.exe Applying migration '20210903083845_MyMigration'. Done. PS C:\local\AllTogetherNow\SixOh> ``` -------------------------------- ### Execute migration bundle with connection string in PowerShell Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/managing-schemas/migrations/applying.md Sets ASPNETCORE_ENVIRONMENT to Production and runs the migration bundle using a connection string environment variable. Use a deployment identity with schema permissions from a secret store. ```powershell $env:ASPNETCORE_ENVIRONMENT = 'Production' .\efbundle.exe --connection $env:DEPLOYMENT_CONNECTION_STRING ``` -------------------------------- ### Install Microsoft.EntityFrameworkCore.Tasks package with .NET CLI Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/what-is-new/ef-core-9.0/whatsnew.md Installs the MSBuild tasks package required for automated compiled model generation. Choose the package version that matches the version of EF Core in use. ```dotnetcli dotnet add package Microsoft.EntityFrameworkCore.Tasks --version 9.0.0 ``` -------------------------------- ### Run list, script, and bundle commands with .NET CLI project options Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/managing-schemas/migrations/projects.md Applies the migrations project to --project and --startup-project across other migration operations such as listing, scripting, and bundling. Repeated project options can also be stored in .config/dotnet-ef.json starting with EF Core 11. ```dotnetcli dotnet ef migrations list \ --project WebApplication1.Migrations \ --startup-project WebApplication1.Migrations dotnet ef migrations script --output artifacts/migrations.sql \ --project WebApplication1.Migrations \ --startup-project WebApplication1.Migrations dotnet ef migrations bundle --output artifacts/efbundle \ --project WebApplication1.Migrations \ --startup-project WebApplication1.Migrations ``` -------------------------------- ### Add migrations and rebuild bundle with --force Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/managing-schemas/migrations/applying.md Adds new migrations and regenerates the migration bundle. Use the --force flag to overwrite the existing bundle executable. ```dotnetcli PS C:\local\AllTogetherNow\SixOh> dotnet ef migrations add SecondMigration Build started... Build succeeded. Done. To undo this action, use 'ef migrations remove' PS C:\local\AllTogetherNow\SixOh> dotnet ef migrations add Number3 Build started... Build succeeded. Done. To undo this action, use 'ef migrations remove' PS C:\local\AllTogetherNow\SixOh> dotnet ef migrations bundle --force Build started... Build succeeded. Building bundle... Done. Migrations Bundle: C:\local\AllTogetherNow\SixOh\efbundle.exe PS C:\local\AllTogetherNow\SixOh> ``` -------------------------------- ### Install EF Core templates package using dotnet new Source: https://github.com/dotnet/entityframework.docs/blob/main/entity-framework/core/managing-schemas/scaffolding/templates.md Installs the EF Core template package for dotnet new. This provides the templates needed to scaffold and customize EF Core reverse engineering. ```dotnetcli dotnet new install Microsoft.EntityFrameworkCore.Templates ```