How to use Core EF to build Instant Web API

Instant Rest API from your MS SQL data source? Since REST utilizes CRUD (Create, Retrieve, Update, and Delete), it is very easy to understand whether you are just starting out as a developer or have years of experience. It can be reused with different projects which saves time as well. It’s also very popular and according to Cloud Elements’ 2017 State of API Integration report, 83 percent of APIs now use REST. Here’s an article which goes into more depth but these are the highlights.

At the end of the day, the best protocol is the one that makes the most sense for the organization, the types of clients that you need to support, and what you need in terms of flexibility. Most new APIs are built using REST and JSON simply because it typically consumes less bandwidth and is easier to understand both for developers implementing initial APIs as well as other developers who may write other services against it. Because it’s more easily consumed by most of today’s web browsers, REST+JSON has become the defacto technology for the majority of public APIs. However, SOAP remains a valuable protocol in some circumstances. Plus, you don’t have to look far to find die-hard fans advocating for SOAP for certain use cases.

Hide Internal Codes: Needless to say, this is an implementation detail that gives away that we are using a relational database, and experienced Oracle users would instantly spot that it’s Oracle’s sample HR schema. This leaking makes it harder to switch to a document-oriented database, like MongoDB, where there is no concept of foreign keys. But even if the chance of switching to MongoDB is zero, it still makes the response harder to read. So a better approach is to let the REST API translate the internal code to the human-readable value that the code represents (i.e. “Shipping Clerk”) and then also remove the Id part of the field name. This version is definitely more readable, but a fair concern is if the service will be slower now that it needs to lookup the value? I used to be an avid reader of Tom Kyte, the Oracle DB expert, and still remember that you should always optimize from measurements. I mean there’s a good chance that the HTTP cache will help us out and make it less of a bottleneck than it appears at first glance. As a rule of thumb, if performance means everything to you (or you have a lot of lookup fields) then you might consider leaking the internal codes. Otherwise, you should provide a more readable API by hiding them.

I see that this software is using Visual Studio 2017. Do I need a license for this product? No, as a single developer you can qualify for the free edition. You can download it from Microsoft site: Visual Studio Community 2017 I don’t have a license for Microsoft SQL Server. Do I need one? No, Microsoft provides a free download for SQL Express Edition server. You can get yours here. I see that a backup of AdventureWorks database is provided with the installation. How can I restore it on the server? In order to restore the backup file please download SSMS from this site: SQL Server Management Studio (SSMS). Once the code is generated am I able to modify it? Yes, by purchasing a license you should be able to modify the code however you see fit. See additional info on Instant Rest API from your MS SQL database.