CRUD WebAPI App with .NET 6 and Swagger API documentation.
- This Web API app is demonstration of CRUD operations with Swagger API documentation for testing APIs.
- Technology used - C#, .NET 6 and Swashbuckle nuget package.
- Clone the project on local directory.
- Go to Solution view from Solution Explorer
- Go to appsettings.json file and copy the ConnectionStrings object
"ConnectionStrings": {
"SqlServerConnection": "server=\\LocalDBServer;database=productsdb;TrustServerCertificate=True;Integrated Security=SSPI"
}
- Go to ProductAPI Project and right click on it and select Manage User Secrets
- paste the ConnectionStrings object in Secrets json file.
"ConnectionStrings": {
"SqlServerConnection": "server=\\LocalDBServer;database=productsdb;TrustServerCertificate=True;Integrated Security=SSPI"
}
- Create database with name 'productsdb' in your SQL Server instance and add Server name and database name in secrets.json
- Now Open Package Manager Console
- Then you need to install Entity Framework Core CLI, so perform below command in Package Manager Console.
dotnet tool install --global dotnet-ef
- Then you need to update changes for database tables to your SQL Server instance, so perform below command in Package Manager Console.
dotnet ef database update --project ProductAPI
- With successfull configuration, now simply select launch type for running project an run the project with F5 key.
- Now project will be running in browser with swagger API documentation page.