This stencil is based on the article - Developing Great Web APIs Architectures w/ ASP.NET Core 2.1 given by Chris Woodruff at QCon.
The design is based on the following and uses very good standard practices:
This stencil will generate the same code used in this presentation. However, the beauty of stencils in CodeStencil is that you can swap and use your own database, define the name of your project, namespaces, etc. and the generated code will automatically use these.
The solution and all code from this article's examples can be found here in Chris' GitHub repository ChinookASPNETCoreAPIHex.
The stencil for this example can be downloaded from here: WebApi on github
These are a few thing to note about this Stencil:
Steps to try this out:
(1) Download and Install the CodeStencil Application.
Note: If you are using BitDefender Anti-virus, it may prevent the installation from finishing.
If this happens, click on the "View Details" and switch on to allow Setup/Uninstall to continue, then click "Retry"
The application should be installed under the Program group - Zera Systems Codestencil/Codestencil
(2) Download the WebAPI Stencil from github: https://github.com/codetstencil/stencils/blob/master/WebAPI.codestencil.zip
(3) Register(Install) the Stencil.
(4) Create a new project. Make sure you Select the WebAPI Stencil:
(5) Import a database Schema
Select all the tables and "Import Schema"
(6) Click on the "Generate" button to start the code generation process
(7) Navigate to the folder that contains the generated code after the generation is complete:
Note: The actual folder will be something like: D:\generated\codestencil\Chinook\src\NorthWind\NorthWind.API depending on where your code is generated.
(8) Open the command prompt in the Nothwind.API folder and call "dotnet run" from there to start the kestrel server:
(9) Test the api by typing: "http://localhost:5027/api/artist" in the browser.
When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.
We use cookies to improve your experience on our website.
Comments