Using Web API 2 with Entity Framework 6
Software versions used in the tutorial
This tutorial uses ASP.NET Web API 2 with Entity Framework 6 to create a web application that manipulates a back-end database. Here is a screen shot of the application that you will create.
The app uses a single-page application (SPA) design. “Single-page application” is the general term for a web application that loads a single HTML page and then updates the page dynamically, instead of loading new pages. After the initial page load, the app talks with the server through AJAX requests. The AJAX requests return JSON data, which the app uses to update the UI.
Here are the main building blocks for this app:
- ASP.NET MVC creates the HTML page.
- ASP.NET Web API handles the AJAX requests and returns JSON data.
- Knockout.js data-binds the HTML elements to the JSON data.
- Entity Framework talks to the database.
Create the Project
Open Visual Studio. From the File menu, select New, then select Project. (Or click New Project on the Start page.)
In the New Project dialog, click Web in the left pane and ASP.NET Web Application in the middle pane. Name the project BookService and click OK.
In the New ASP.NET Project dialog, select the Web API template.
If you want to host the project in a Microsoft Azure Website, leave the Host in the cloud box checked.
Click OK to create the project.
Configure Azure Settings (Optional)
If you left the Host in Cloud option checked, Visual Studio will prompt you to sign in to Microsoft Azure
After you sign in to Azure, Visual Studio prompts you to configure the Azure Websites. Enter a name for the site, select your Azure subscription, and select a geographical region. Under Database server, select Create new server. Enter an administrator username and password.
This article was originally created on June 16, 2014