Building an application with Angular2, Dotnet Core, Web API and Entity Framework

This is the first in a multi-part blog series where I will discuss building an application using Angular2, Typescript, Webpack, .NET Core, Web API and Entity Framework.

Introduction

I tend to skip through long blog posts, espcially those littered with screenshots of Visual Studio dialogs or similar. I like to get to the point when reading blogs and aim to do the same when writing them. That said, the series wouldn’t be complete without a brief introduction to each of these technologies.

Technologies We’re Using:

  • Angular2
    Angular has been an extremely popular framework for building the client side of web applications, typically of the single page variety (SPAs) as well as being the core behind the popular mobile framework, Ionic. Now in version 2, this popular framework has become even more powerful allowing you to build applications using modern javascript (ES5, ES6) and Typescript while utilizing modern application concepts like Web Components. Ionic 2 has also followed suit. For more information see http://angular.io

TypeScript

TypeScript has become an indespenable tool for probably the majority of Javascript developers. While some prefer to work in straight javascript, the benefits of typed Javascript have become extremely compelling. Unlike pre-comilers like CoffeeScript, TypeScript is a pure superset of JavaScript. And while developed by Microsoft it has been fully empraced by Google, who, at least for Angular 2 has actually endorsed it in favor of their own pre-compiler known as Dart. For more information see https://www.typescriptlang.org/

Webpack

Early releases of Angular focused on System.js for module loading. Since then, the Angular team has fully embraced Webpack which has become the tool of choice for build scripting, bundling and module loading. Honestly Webpack is a big topic that I’m only beginning to grasp so I will give a brief introduction to this topic. For more information see http://webpack.github.io/

.NET Core

.NET is a huge subject and no-doubt if you’re reading this you are very familiar with it. .NET Core is its newest incarnation and is the first version that can run cross-platform. As long as we don’t need any features in standard .NET, I’d like to build the application in .NET Core even though I will most likely only be hosting the application on Windows.

Web API

.NET Web API is the server-side technology that we’ll use to create your REST server. There are many other choices that we could have used such as Node.js or Java, but for me .NET Web API is a powerful choice that lets us develop our backend quickly while utilizing a language that I know very well, C#.

Entity Framework

We’ll be building out our persistence using Entity Framework and SQL Server. I’ll briefly cover Code first migrations and how to build a data access layer using Entity Framework and how to provide that our Web API layer.

Connect.Tech 2016

I’m attending this year’s Connect Tech conference in Marietta, GA. This is a conference focusing on web, mobile, javascript and related technologies. This is typically the weekend I attend the Head of the Charles regatta. Unfortunately for a variety of reasons, I’m not attending this year so figured I’d get in some geek learning.

Hexo 3.0 and new theme

Before I mention the details of the conference, it behooves me to mention that I’ve just updated my site to the new version of Hexo. It was past due to do so and I decided also to update my theme. Pretty nifty I think.

angularjs

I’ve been developing in Angular for a while now, and I am trying to learn some of the best techniques for developing new Angular 2.0 application as well as learning about refactoring, profiling and migrating Angular 1 apps. Despite 1 or 2 mediocre to poor sessions, there have been some good sessions on Angular 1 performance, in particular “Scaling large Angular 1 apps” by Jad Joubran.

webpack

Webpack is becoming the go-to tool for bundling, minifying and packaging your web applications. It’s a powerful yet confusing tool. John Mercer’s session “Webpack: A Simple Introduction to a Complex Tool” helped clear up some of the confusion.

NativeScript

NativeScript is an interesting tool for developing native Android, IOS and Windows Phone applications. Jen Looper‘s session on Angular 2 with NativeScript was a very creative, quick intro to NativeScript while writing an interesting app using the SoundCloud API.

Progressive Web Apps and more…

I’m about to sit in on a session about Angular 2 and Progressive Web Apps. More on that and other topics next time…

VisualCV

I just got started with a new service called Visual CV. It seems like a pretty handy way to post a resume online. They have various themes, though I’m using the free one. You can import your resume from various sources, but I decided to import mine from LinkedIn. That way I can use LinkedIn as my master source and generate both an online and PDF version from it.

Once I imported my resume, it is available online at: (https://www.visualcv.com/tdekoekkoek) or on my blog at (http://tdekoekkoek.github.io/Resume/)

Now if only I can just get my LinkedIn profile up to date!

Getting started with hexo

Yes I’m rebuilding my blog from scratch yet again. My previous blog was done in Ghost and I didn’t keep it live. I have now decided to relaunch my blog on github pages.

Static Site Generators

I first tried out some static site generators like DocPad and Jekyl some time ago, but I ended up creating my blog in Ghost. Since that time I’ve decided to revisit static sites for a number of reasons:

  • My Ghost Blog needs to be replaced
  • I like the idea of hosting my blog on github pages
  • I like having full control of my markup so that I can host Angular samples and applictions directly in my blog
  • It’s the latest thing all the cool kids are doing these days.

Introducing Hexo

Hexo is a powerful static blog generator. I tried a number of other static site generators and either it was difficult to get blogging going without a lot of extra work or they required Ruby. I was really looking for a Javascript only solution. So I gave Hexo a try. I’ve found it not only quite powerful, but well documented and extremely easy to set up. There are also a number of themes available.

So far I’m quite happy with my choice. Hexo uses Markdown or Html for editing content and uses EJS and Swig for templating. However you really don’t need to know anything about EJS or Swig to use Hexo.

Getting Started

Installing hexo is dead simple. You just need to make sure you have Node and npm already set up. If you’re not familiar with node, head on over to http://nodejs.org/ to learn about it and to install it. Borrowing from the Hello World documents, you can get started with Hexo as follows:

Installation

1
$ npm install -g hexo

More info: Getting Started

Create a new post

1
$ hexo new "My New Post"

More info: Writing

Run server

1
$ hexo server

More info: Server

Generate static files

1
$ hexo generate

More info: Generating

Deploy to remote sites

1
$ hexo deploy

More info: Deployment

Markdown

Once you’re up and running with Hexo you’ll want to get a simple markdown editor. Right now I’m just typing in Brackets (a very cool editor by the way), but I’ll probably look into some online Markdown editors or perhaps a windows program or maybe just create a simple Angular app with ShowDown. We’ll explore that another time.

|