Simple example of Database-First approach using Entity Franework Core.
Microsoft.EntityFrameworkCore.Design
Npgsql.EntityFrameworkCore.PostgreSQL
Microsoft.EntityFrameworkCore.SqlServer
-
dotnet ef dbcontext scaffold "Data Source=DESKTOP-P87PH2B;Initial Catalog=CodeFirstEntityFramework;Integrated Security=true;" Microsoft.EntityFrameworkCore.SqlServer -o SqlServerScaffold
-
dotnet ef dbcontext scaffold "Server=localhost;User Id=postgres;Password=postgres;Database=CodeFirstEntityFramework;" Npgsql.EntityFrameworkCore.PostgreSQL -o PostgreSqlScaffold
Consider the case when we have a connection string to some database we want to reverse engineer.
Consider the database CodeFirstEntityFrameworkCore
We have following connection strings:
"Server=localhost;User Id=postgres;Password=postgres;Database=CodeFirstEntityFramework;"
"Data Source=DESKTOP-P87PH2B;Initial Catalog=CodeFirstEntityFramework;Integrated Security=true;"
Using the commands:
-
PostgreSQL:
dotnet ef dbcontext scaffold "Server=localhost;User Id=postgres;Password=postgres;Database=CodeFirstEntityFramework;" Npgsql.EntityFrameworkCore.PostgreSQL -o PostgreSqlScaffold
-
MS SQL Server:
dotnet ef dbcontext scaffold "Data Source=DESKTOP-P87PH2B;Initial Catalog=CodeFirstEntityFramework;Integrated Security=true;" Microsoft.EntityFrameworkCore.SqlServer -o SqlServerScaffold