Install EF first:

dotnet tool install --global dotnet-ef

Prepare a clean .NET project: MINGW64 ~/Desktop
$ mkdir Temp MINGW64 ~/Desktop
$ cd Temp/ MINGW64 ~/Desktop/Temp
$ dotnet new console
Getting ready...
The template "Console Application" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on C:\Users\xuef\Desktop\Temp\Temp.csproj...
  Determining projects to restore...
  Restored C:\Users\xuef\Desktop\Temp\Temp.csproj (in 61 ms).
Restore succeeded. MINGW64 ~/Desktop/Temp
$ ls
obj/  Program.cs  Temp.csproj

Before further steps, install some required dependencies: MINGW64 ~/Desktop/Temp
$ dotnet add package Microsoft.EntityFrameworkCore.SqlServer Microsoft.EntityFrameworkCore.Design --interactive

And try to execute the following command under your project folder to reverse the database:

$ dotnet ef dbcontext scaffold "Server=....." Microsoft.EntityFrameworkCore.SqlServer -o Models

And fill the string Server=..... with your database connection string. Make sure that you can connect to this database successfully. MINGW64 ~/Desktop/Temp
$ dotnet ef dbcontext scaffold "Data;Initial Catalog=bbbbbbb;User ID=mydatabase;Password=cccc
ccccc" Microsoft.EntityFrameworkCore.SqlServer -o Models --table EmergencyPatchAttempts
Build started...
Build succeeded.
To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection
string by using the Name= syntax to read it from configuration - see For more guidance on storing conne
ction strings, see


And EF will try to build models from the database.


Note: Once you have created the model, you must use the Migration commands whenever you change the model to keep the database up to date with the model.