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

Treehouse

Entity Framework Basics Course (How To)

via Treehouse

Overview

In this course, you'll learn how to use Microsoft's Entity Framework to persist application data to a database. By the end of the course, you'll have learned how to use the Code First workflow, create entity classes, write LINQ queries, perform CRUD operations, and more.

What you'll learn

  • Code First Workflow
  • Creating Entity Classes
  • Defining Relationships Between Entities
  • Writing Queries Using LINQ
  • Performing CRUD Operations Using the Context

Syllabus

Introducing Entity Framework

We'll start with an introduction of Entity Framework, including an overview of the Database First and Model First workflows. Then we'll use the Code First workflow to add our first entity class and database context class. We'll also see how to use the context to add an entity to the database and retrieve a list of entities from the database.

Chevron 11 steps
  • Welcome to Entity Framework Basics

    2:37

  • What is Entity Framework?

    4:19

  • Entity Framework Review

    5 questions

  • Workflows: Database First

    6:19

  • Workflows: Model First

    5:50

  • Adding Our First Entity Using the Code First Workflow

    6:02

  • Adding an Entity

    2 objectives

  • Adding Our Context

    3:03

  • Adding a Context

    2 objectives

  • Using the Context

    5:03

  • Section Review

    10 questions

Entity Framework and Databases

We'll see how to confirm that SQL Server LocalDB is installed and configured correctly for Entity Framework. We'll also locate and review the database that EF generated for us in the previous section, customize the database name, and configure EF's database initializer.

Chevron 8 steps
  • Database Server Installation and Configuration

    6:16

  • LocalDB Review

    5 questions

  • Where's Our Data?

    7:14

  • Changing the Database Name

    7:50

  • Changing the Database Name

    2 objectives

  • Controlling Database Generation

    5:08

  • Controlling Database Generation

    1 objective

  • Section Review

    10 questions

Extending Our Entity Data Model

We'll extend our model by adding entities and defining relationships between our entities. Then we'll see how to refine our model using data annotation attributes on our entities or by using the fluent API. We'll also see how to use a custom database initializer to seed our database with data.

Chevron 14 steps
  • Adding a One-to-Many Entity Relationship

    5:48

  • Using a One-to-Many Relationship

    8:35

  • Defining a Foreign Key Property

    2:59

  • Defining and Using a One-to-Many Relationship

    2 objectives

  • Adding a Many-to-Many Relationship

    10:33

  • Defining a Many-to-Many Relationship

    2 objectives

  • Defining a Many-to-Many Relationship with an Explicit Bridge Entity

    10:25

  • Defining a Many-to-Many Relationship with an Explicit Bridge Entity

    3 objectives

  • Using Data Annotations to Refine the Generated Database

    5:58

  • Refining a Model Using Data Annotations

    1 objective

  • Overriding the Context's OnModelCreating Method

    6:33

  • Using the Fluent API

    1 objective

  • Populating Your Database with Seed Data

    5:55

  • Section Review

    10 questions

LINQ Queries

We'll see how to write LINQ to Entities queries including how to filter and sort data. Then we'll see the options that EF gives us for loading related data and how they compare to one another. We'll also see the options that EF provides for retrieving a single entity from the context.

Chevron 10 steps
  • List Queries

    6:10

  • Writing a List Query

    1 objective

  • Filtering Queries

    4:22

  • Filtering a Query

    1 objective

  • Sorting Queries

    4:57

  • Sorting a Query

    1 objective

  • Loading Related Entities

    11:05

  • Detail Queries

    9:35

  • Writing a Detail Query

    1 objective

  • Section Review

    10 questions

CRUD Operations

We'll take a look at a console application that was built on top of our comic book model. We'll also learn how to perform CRUD operations with the database context. As we do that, we'll implement various Repository class methods in the console application.

Chevron 9 steps
  • Data Access Layers

    4:07

  • Creating Entities

    9:22

  • Creating an Entity

    1 objective

  • Updating Entities

    9:12

  • Updating an Entity

    1 objective

  • Deleting Entities

    5:02

  • Deleting an Entity

    1 objective

  • Wrap Up

    2:16

  • Section Review

    10 questions

Reviews

Start your review of Entity Framework Basics 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.