This guide explains how to set up Entity Framework Core with Pomelo MySQL Provider using Scaffold-DbContext command.
- .NET Core SDK installed
- Pomelo.EntityFrameworkCore.MySql package installed
- Access to a MySQL database
- Open a terminal or command prompt.
- Run the following Scaffold-DbContext command, replacing the connection string with your own:
Scaffold-DbContext "Server=localhost;Port=3307;Database=erpcrm;User=root;Password=root;Persist Security Info=False;Allow Zero Datetime=True;Connect Timeout=300" Pomelo.EntityFrameworkCore.MySql -OutputDir Models -f -Context DBContext - This command will generate the required models based on your database schema in the specified output directory.
-
Clone the Repository
Clone this repository using Git: -
Install .NET 8 or higher from source If you don't have .NET 8 installed, you can install it by following the official installation guide. Make sure to install the correct version for your operating system.
-
Restore Dependencies Run the following command to restore the project dependencies:
dotnet restore
-
Configure the Database Connection Open the appsettings.json file and replace the DefaultConnection connection string with your own mysql connection string.
{
"ConnectionStrings": {
"DefaultConnection": "Server=localhost;Port=3307;Database=erpcrm;User=root;Password=root;Persist Security Info=False;Allow Zero Datetime=True;Connect Timeout=300"
}
}-
Restore the Database from dbbackup folder there is a SQL backup file located in the dbbackup folder, restore the database using the MySQL command line or any MySQL workbench.
-
Run the Application After configuring the connection string and restoring the database, run the application using the following command:
dotnet run- Default Credentials The default email is abc@gmail.com and the default password is 1234.
- Ensure that you have proper permissions to access the database.
- Adjust the command parameters as per your specific database configuration.
- Make sure to replace sensitive information like passwords before sharing or committing to version control.
For more information on Pomelo MySQL Provider, refer to the official documentation.