Entity Framework
.NET
Database
Model Generation
Instructions are for .NET 7
MySQL
dotnet new console –o applicationName
cd applicationName
dotnet add package MySql.EntityFrameworkCore --version 7.0.2
dotnet add package Microsoft.EntityFrameworkCore.Tools --version 7.0.14
If the Entity Framework tool is not already installed:
dotnet tool install --global dotnet-ef --version 7.*
Then, generate the model files in the models directory:
dotnet ef dbcontext scaffold "server=127.0.0.1;port=3306;uid=jimc;pwd=password;database=database_name" MySql.EntityFrameworkCore -o models -f
SQL Server
dotnet new console –o applicationName
cd applicationName
dotnet add package Microsoft.EntityFrameworkCore.SqlServer --version 7.0.14
dotnet add package Microsoft.EntityFrameworkCore.Tools --version 7.0.14
If the Entity Framework tool is not already installed:
dotnet tool install --global dotnet-ef --version 7.*
Then, generate the model files in the models directory:
dotnet ef dbcontext scaffold "Server=server_ip_address;User Id=sa;Password=password;Database=database_name;Encrypt = No" Microsoft.EntityFrameworkCore.SqlServer -o models -f