Building a Maintainable Web App with Web API 2 and Entity Framework 6: Part 0

One of the great aspects of learning how to become a software engineer is the vast collection of free content available on the web. For example, Microsoft's ASP.NET site is a great resource for learning the basics of their web development technologies with tons of sample projects, code, walkthroughs, etc. However, the vast majority of these examples are relatively simple; this is a necesssary result of attempting to highlight a specific technology without over-complicating the code base with a complex business domain or heavy use of other technologies with which the reader may be unfamiliar.

I recently came across one such example here. The article is an introduction to using Web API 2 and Entity Framework 6 to build a single page application (SPA). While the author Mike Wasson does a great job of introducing these concepts, much of the underlying code is not easily maintainable, and as such would not be acceptable for our client projects at feature[23].

This is the first post in a series on building maintainable web apps. The basic premise is that the code in the above-referenced article was written as a proof-of-concept prototype, the project has been greenlighted, and we're going to pay down the technical debt before further development. Each subsequent post will highlight an item of technical debt, why it's technical debt, and strategies to pay it down. Once we are satisified with our debt level, we'll introduce one or more new features to see how well they scale.

Prerequisites
  • A basic understanding of C#, .NET and object-oriented principles (i.e. be familiar with classes, interfaces, methods, multi-project solutions, etc.).
  • Familiarity with the ASP.NET MVC architecture (a decent introduction can be found here).
  • A basic understanding of HTML, CSS and JavaScript (or you can skip over posts covering client side if you'd like).
  • A little bit of git and GitHub knowledge wouldn't hurt, either.
  • If you'd like to code along at home, I'm using Visual Studio 2015 Enterprise (though the Community edition should work fine) and SQL Server Express 2014 with SQL Server Management Studio.
Required Reading
  • The original article on the ASP.NET site (I won't be walking through this as the author has already done an excellent job in that regard).
  • Code on GitHub. The master repo for this article is here, and you can find the author's repo here. I'll keep the branch original-asp-net-code and any new feature branches in the repo for reference, but changes as this project develops will be merged into master.

First, we'll tackle the server side, and then move on to the client side. I don't have a timeline on posts at this point, so feel free to subscribe to this blog, follow me on the Twitter, or just check back on occasion.

The next post will cover why EF migrations aren't maintainable and how we can use SQL Server Database Projects to more easily manage changes to our data schema.