Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

Treehouse

Entity Framework with ASP.NET MVC Course (How To)

via Treehouse

Overview

In Entity Framework Basics, you learned how to use Entity Framework to persist data to a database within the context of a console application. In this course, you'll learn how to use Entity Framework within the Comic Book Library Manager web app—a web application developed using the ASP.NET MVC web framework. You'll work on completing this web app so that users can create, update, and delete comic books from their digital library.

Throughout this course you'll learn by example by completing hands-on coding exercises. See how to put EF related code into its own class library project, retrieve and persist data from within a web app, organize your data access code using popular design patterns, and more!

What you'll learn

  • Leveraging Class Library Projects
  • Adding EF to an ASP.NET MVC Project
  • Managing the Context's Lifetime
  • Using Data Access Design Patterns

Syllabus

Project Setup

We'll start by taking a look at the Comic Book Library Manager web app. Then we'll add class library and ASP.NET MVC projects to the existing Comic Book Library Manager console app project's Visual Studio solution. We'll also add a set of starter files to our MVC project and see how you can use a view model to supply data to a view.

Chevron 6 steps
  • Using Entity Framework with MVC Web Apps

    2:30

  • Introducing the Comic Book Library Manager Web App

    4:05

  • Adding the Class Library Project

    8:32

  • Adding the ASP.NET MVC Project

    6:22

  • Reviewing the Provided Project Code

    6:37

  • Section Review

    5 questions

Entity Framework and ASP.NET MVC

Now that we have our solution setup, we'll configure EF and update the comic books controller to use EF for all of its data retrieval and persistence. Along the way, we'll see how we can hook into the controller's lifetime in order to manage the lifetime of the database context. You'll also have the chance to work on a hands-on exercise as you finish the comic book artists controller.

Chevron 9 steps
  • Preparing Our Plan

    5:09

  • Configuring Entity Framework

    5:03

  • Handling Reads

    9:00

  • Managing the Context's Lifetime

    5:11

  • Handling Creates and Updates

    6:34

  • Handling Deletes

    8:28

  • Exercise: Finishing the Comic Book Artists Controller

    4:04

  • Solution: Finishing the Comic Book Artists Controller

    4:36

  • Section Review

    5 questions

Data Access Design Patterns

Now that our web app has been updated to use EF, we'll look at some ways we can improve the design and organization of our data access code. We'll see how we can use the repository pattern in a variety of ways including creating a generic base repository class to help facilitate implementing entity-type-focused repositories. We'll also take a look at using query and command classes as an alternative to using repositories.

Chevron 9 steps
  • Adding a Base Controller Class

    6:56

  • Using the Repository Pattern

    6:40

  • Reviewing the Completed Repository

    6:16

  • Breaking Apart Our Repository

    9:22

  • Reviewing the Comic Book Artists Repository

    3:36

  • Creating a Generic Base Repository Class

    12:24

  • Using Our Generic Base Repository Class

    6:02

  • Alternatives to Using Repositories

    12:49

  • Section Review

    5 questions

Completing the Project

We'll complete the course with a set of exercises for you to complete: one exercise to finish the "Series" section and another to finish the "Artists" section.

Chevron 5 steps
  • Exercise: Finishing the "Series" Section

    4:35

  • Solution: Finishing the "Series" Section

    6:13

  • Exercise: Finishing the "Artists" Section

    4:02

  • Solution: Finishing the "Artists" Section

    7:41

  • Section Review

    5 questions

Reviews

Start your review of Entity Framework with ASP.NET MVC Course (How To)

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.