Introduction
This article will give developers a practical way to build a Web API with ASP.NET Core and Entity Framework to call Stored procedure. This way will be the simplest and most practical for developers to do a Web API job for any kind of database with the least accesses.
At the beginning of the article, I will give some basic background for Microservice architecture and Web API. For seasonal developers, you can skip A, B, C, and jump to D: Web API implementation.
A, Software Development Architecture
Software development architectures have evolved as described below"
- Server-side programming, such as IBM mainframe or UNIX server with a dumn terminal
- Client-side programming, such as HTML page with Dynamic javascript
- Client-server architecture, such as ASP webserver/page
- Three-tier architecture, enterprise business architecture
- SOA: service-oriented architecture, also loose-coupled enterprise business architecture
- Microservice architecture: loose-coupled architecture with application scope
Server-side programming, Client-side programming, Client/Server architecture, and Three-tier architecture are monolithic architecture, while SOA and Microservice architecture is loose-coupled architecture. The latter has advantages such as being built with different languages in different platforms, isolated and loose-coupled, extremely scalable, and so on.
Microservices Architecture
Highly scalable, flexible applications by decomposing the application into discrete services that implement specific business functions, often referred to as “loosely coupled,” can then be built, deployed, and scaled independently. It is the trend of software development.

B, Web API, the role in Microservice
The Microservice basically includes two parts: Client and API. The client is the consumer that could be applications of a smartphone, tablet, Windows, Mac, or any kind of browsers. The APi (Application Programming Interface) is the service provider that could be accessed by any or all of the kind of Clients, i.e, the RESTful service, or JSON format output.
Theoretically, API could be built by any languages or any platforms or any devices, while ASP.NET Web API is a Microsoft tool to produce the RESTful output through HTTP for Clients. It works more or less the same way as the ASP.NET MVC web application except that it sends data as a response instead of an HTML view.
C, Choices of Web API implementation
The RESTful service is basically returning data to clients. In most cases, we get the data from the database stored procedure. How to talk to the database? Even if we choose Web API as a tool to build RESTful service, and specifically, using C# as language, we still have different choices for implementation, such as:
1, Using ADO.NET






Join the conversation! Your thoughts help the community grow.