Introduction
In this article, we are going to create a product management web API with CRUD operations using .NET Core 6 and different forms with the help of React JS.
Prerequisites
- Visual Studio 2022
- VS Code
- SQL Server
- .NET Core SDK
- Node JS
Product Management Application
Step 1. Create a new Product Management .NET Core Web API.
Step 2. Install the following NuGet packages that we used for database migrations and connectivity with SQL Server.
![Packages]()
Step 3. Add the product class inside the entities folder.
Step 4. Create an AppDbContext class inside the data folder with a SQL Server connection and a DB set property.
Step 5. Add a product repository inside the repositories folder.
IProductRepository
ProductRepository
Step 6. Create a new product controller with different action methods that we used to perform different operations using our front-end application after invoking the same.
Step 7. Open the app settings file and add the database connection string.
Step 8. Register our services inside the service container and configure the middleware.
Step 9. Execute the following entity framework database migration command to create a database and tables.
Step 10. Finally, run the application and use Swagger UI to execute different API endpoints.
![Product Manager API]()
Create a client application using React JS
Let’s create a client application using React JS and consume the above API endpoints within it.
Step 1. Create a new React JS application with the help of the following command:.
Step 2. Navigate to your project directory.
Step 3. Install Axios to consume and hit backend API and bootstrap for designing purposes.
Step 4. Add the following components and services:.
Product list component.
Product list item component.
Product service.
App component.
Step 5. Run the application using the following command and perform the different CRUD operations with the help of the same.
![Run the application]()
Github: https://github.com/Jaydeep-007/React_NETCore_CRUD
Conclusion
In this article, we created a product management backend application using .NET Core and SQL Server with different API endpoints that are required to perform CRUD operations. Later on, I created the front-end application using React JS and consumed the back-end application inside the same with the help of Axios.