Scaffold Database (PostGres)

Créer un projet C# ASP Net Core

Il faut ajouter le Nuget correspondant à Postgres dans le projet avec les commandes suivantes

Install-Package Microsoft.EntityFrameworkCore.Design
Install-Package Npgsql.EntityFrameworkCore.PostgreSQL

Installing the tools

dotnet ef can be installed as either a global or local tool. Most developers prefer installing dotnet ef as a global tool using the following command:

.NET Core CLI
dotnet tool install --global dotnet-ef

To use it as a local tool, restore the dependencies of a project that declares it as a tooling dependency using a tool manifest file.

Update the tool using the following command:

.NET Core CLI
dotnet tool update --global dotnet-ef

Verify installation

Run the following commands to verify that EF Core CLI tools are correctly installed:

.NET Core CLI
dotnet ef

The output from the command identifies the version of the tools in use:

Output
                     _/\__
               ---==/    \\
         ___  ___   |.    \|\
        | __|| __|  |  )   \\\
        | _| | _|   \_/ |  //|\\
        |___||_|       /   \\\/\\

Entity Framework Core .NET Command-line Tools 2.1.3-rtm-32065

<Usage documentation follows, not shown.>
dotnet ef dbcontext scaffold "Server=localhost;Database=Test;Username=postgres;Password=password" Npgsql.EntityFrameworkCore.PostgreSQL -o Models

 


Revision #4
Created Wed, Apr 21, 2021 5:11 AM by Nelson
Updated Thu, Apr 22, 2021 8:47 AM by Nelson