O'Reilly logo
live online training icon Live Online training

Web Application Programming in C# and ASP.NET Core with MVC and Entity Framework

Learn to create modern web sites and REST services in C# for .NET core

Riccardo Audano

The next step after you have acquired a decent grasp on C# and Object Oriented programming is exploring the world of web applications and web services. This can be a bit daunting, as you have to absorb some new fundamental ideas together with quite a few configuration details, and it can be difficult at first glance to discern what is really important and fundamental, from what is just detail that you can look up when you need it. This course is designed with the idea of giving you a quick but solid introduction to the fundamental ideas and practices necessary to build MVC Core Web sites and REST services.

What you'll learn-and how you can apply it

By the end of this online course you will understand:

  • What is the MVC pattern and why it’s so relevant to web applications
  • How the MVC Core framework implements the MVC pattern
  • How controllers, model and views interact and why we need View Models
  • What is Dependency Injection and why it's so useful
  • How to construct Views mixing HTML and Razor syntax
  • What is a ORM and we can leverage Entity Framework Core to connect with the database
  • The Repository and Unit of Work Patterns
  • What is a REST service

And you will be able to:

  • Begin writing modern and flexible web applications or REST services
  • Use a clear separation of concern in your web application
  • Handle your database with Entity Framework
  • Create web services the follow the REST
  • Secure your applications with ASP.NET Identity

This training course is for you because...

You have a background in Object Oriented Programming in C# but are new to web applications, or have experience with the “old” ASP.NET Web Forms framework. The course could also be useful if you have experience with the “classic” MVC framework but have not yet had time the new features brought by the core version.

Prerequisites

Working knowledge of the C# language and a basic understanding of class inheritance, interface implementation and method overrides.

About your instructor

  • Riccardo Audano is a developer and tech trainer with more than 15 years of professional experience. He suspects that his not so linear course of studies and interests development has helped him to integrate some of the strengths of the humanities, pure science and coding, starting with the classical studies of his high school, then getting his bachelor and MS in Astronomy, and finally making the choice (with sometimes he regrets, sometimes not) to leave the academia and go work "in the real world". Coming from a background in C/C++ he naturally evolved to Java and C# while getting more and more interested in object oriented principles, design and architecture. He loves programming, but has gradually found out that there's something he likes even more, and that is teaching programming, getting more people into the field and helping existing developers to progress in their understanding and career. Along the years he's taught classes in UML. C/C++/C#. Java, JavaScript, PHP, T-SQL, PL/SQL and Python. He prefers a very interactive teaching style, based on "learning sessions" and not "lessons" and always strives to make them lively, informal and fun. To this extent, he thinks that for a fun introduction to programming nothing beats game programming, so he often uses Unity3D, LibGDX and Phaser in his intro classes.

    When he's not obsessing with coding he's probably travelling, or trying to improve his French and Portuguese and dreaming about learning Chinese, or playing any sport that's played with a racket, be it tennis, beach tennis or paddle, and this is the only activity where you will find him yelling and cursing even louder than when a line of code does not behave as he thinks it should.

Schedule

The timeframes are only estimates and may vary according to how the class is progressing

Day 1

Section 1: Introduction to the MVC framework (40 mins)

  • How web applications work
  • The Model View Controller Pattern
  • Structure and configuration of a MVC Core project with Visual Studio 2017
  • Controllers
  • Model
  • Views

Exercise: handle a simple request with MVC Core (15 mins)

Break (5 mins)

Section 2: Anatomy of an MVC Core web app (40 mins)

  • The razor view engine syntax
  • What are ViewModels and why we need them.
  • Services

Exercise: handle a more complex request with MVC Core (10 mins)

Break (10 mins)

Section 3: Introducing Entity Framework (40 mins)

  • What is an ORM and why it’s so useful
  • Mapping a simple domain model to Entity Framework
  • Crud operations with Entity Framework

Exercise: implement a CRUD operation with Entity Framework (10 mins)

Break (10 mins)

Section 4: More complex operation, and evolving the database (35 mins)

  • Managing transactions
  • Evolving the domain model and database with migrations

Exercise: extend an EF domain model with a migration and perform an operation on it (10 mins)

Section 5: Recap and Q&A (approx 15 mins)

Day 2

Section 5: Clean architecture: repositories (45 mins)

  • The Inversion of Control and Dependency Inversion Principle
  • The need for interfaces
  • Decoupling the front end layer from the database layer with repositories
  • Dependency Injection in MVC Core

Exercise: create and use a simple Repository (10 mins)

Break (5 mins)

Section 6: Clean architecture: The unit of work patterns (35 mins)

  • Orchestrating repositories : the Unit of Work pattern
  • Unit testing Controllers and Unit of Work

Exercise: database access with the unit of work pattern (15 mins)

Break (10 mins)

Section 6: REST services (45 mins)

  • Introduction to web services
  • What it means to be RESTful
  • RESTful CRUD APIs
  • What are DTOs and why we need them
  • Testing the service with Postman

Exercise: creating a simple REST service (approx 10 mins)

Break (5 mins)

Section 7: Crosscutting concerns (45 mins)

  • Adding security to an application with ASP.NET Identity
  • Exception Handling
  • Logging

Section 8: Final recap, Q&A (approx 15 mins)