4.09 out of 5
4.09
77 reviews on Udemy

Learning Entity Framework Core

Learning Entity Framework Core from scratch for building efficient and secure web applications
Instructor:
Packt Publishing
368 students enrolled
English [Auto-generated]
Explore object-relational mapping
Install Entity Framework Core
Create a database context
Create, execute, and roll back migrations
Execute complex relational models
Seed the database
Write custom SQL queries
Work with existing databases

Entity Framework is a highly recommended Object Relation Mapping tool used to build complex systems. This course provides a full learning path to getting productive with the Entity Framework Core. Designed with the intermediate developer in mind and utilizing all of the latest features introduced by EF Core 2.0 and ASP.NET Core 2.0.

In this course, you will learn how to create, execute and rollback your own migrations. You will also get familiar with everything you need to create complex relational models. You will explore some of the most important advanced features of the entity framework like shadow properties, database generated values and raw SQL queries. You will know how to take an existing database and write a project based upon it with minimal intervention.

By the end of this course, you will certainly have added Entity Framework Core to your toolbox.

About The Author

Dimitris Loukas is a software engineer currently writing Single Page Applications and APIs using Aurelia, ASP.NET Core, and Entity Framework for a trading software firm. He is also finishing his Computer Science studies at the University of Athens. He has worked for two start-ups in the past, is active in the open source community, and loves taking up small side projects. He is fascinated by modern JavaScript, C#, and the .NET Core.

Introduction to Entity Framework Core

1
The Course Overview

This video provides an overview of the entire course.

2
What is an O/RM

Some of the viewers might not have any prior experiences with O/RMs so they might not know what an O/RM is.

• Understand O/RM
• Learn about EF Core

3
Starting a New Project

We need to work on a small starting project.

• Start a new ASP.NET Core 2.0 project
• Install Entity Framework Core along with its SQL Server provider using NuGet
• Add a connection string to appsettings.json

4
The Database Context

The Database context is vital to application development with Entity Framework Core. The viewers need to know more about it.

• Show an example of DbContext
• Create a new DbContext
• Add two DbSets to the newly created DbContext

5
Creating the Database

The viewers have created a new project, installed EF Core and even created a DbContext but they haven’t yet seen a database.

• Register the DbContext with DI
• Create a static DbInit class
• Get an instance of the DbContext and call EnsureCreated

6
The SQL Server Object Explorer

The viewers would want to view the fake data inserted in the database. The SQL Server Object Explorer is a very helpful tool for that job.

• Pull up the SQL Server Object Explorer
• Use the View Data feature
• Drop the database

7
Introduction to Entity Framework Core

Now that you are done with the videos of section 1, let’s assess your learning. Here, are a few questions; followed by 4 options, out of which 1 is the correct option. Select the right option and validate your learning!

Create, Execute, and Roll Back Migrations

1
What is a Migration

Viewers without prior exposure to O/RMs have no knowledge of what an O/RM is.

• Provide a detailed explanation of what migrations are
• Describe the advantages of using migrations

2
Our First Migration

Following a theoretical introduction the viewers will need to know how to create their own migrations.

• Add entities to the project
• Add a DbContext
• Execute the migrations and update the database

3
Updating a Table

In order to demonstrate one of the key benefits of using migrations we need to attempt to update a table.

• Make the change in the model
• Create a new migration
• Execute the migration and inspect the change in SQL Server Object Explorer

4
Rolling Back

After having created and updated a table the viewers will want to know how they can go a step back.

• Make an intentional mistake during the creation of an entity
• Apply that migration
• Roll back to a correct state

5
An Alternative: The Command Prompt

In the videos so far we’ve used the PMC to work with migrations. Migrations are still possible with the command line.

• Create a new project add entities and a DbContext
• Guide the viewer through the installation of the required packages
• Demonstrate the basic migration operations in the CMD

6
Create, Execute and Roll Back Migrations

Now that you are done with the videos of section 1, let’s assess your learning. Here, are a few questions, followed by 4 options, out of which 1 is the correct option. Select the right option and validate your learning!

Create Models and Connect Them Through Relationships

1
Restricting Length

You need to start off with something simple like restricting max length.

• Use the MaxLength attribute in a model
• Describe what changes in the migration when we use [MaxLength]

2
Setting a Primary Key

In this video, you’ll get introduced to the concept of primary keys with EF Core.

• Set a primary key by convention
• Set a Primary Key using the Fluent API

3
Unique Fields

Unique fields that are not primary keys are `a fairly common trait in database oriented applications.

• Create a unique constraint using alternate keys
• Create a unique constraint using indexes
• Understand about the indexes

4
Including and Excluding Properties

Sometimes there are properties that you need in the model but not in the database.

• Use the [NotMapped] attribute indicate that the field should not be included

5
Database Generated Values

Work with default and database generated values.

• Create a default value for a field using the Fluent API
• Mark that value as database generated
• Learn about Database Generated attribute does not configure generation on its own

6
Shadow Properties
7
Relationships: One to One

Introduce the viewer to relationships in general and one-to-one relationships in particular.

• Give a brief talk on relationships
• Establish a one-to-one relationship using conventions
• Do the same with the Fluent API

8
Relationships: One to Many

Work with one-to-many relationships.

• Use conventions to establish a one-to-many relationship
• Pave the way for the next video on many-to-many relationships

9
Relationships: Many to Many

Demonstrate how to use two one-to-many relationships to establish a many-to-many relationship.

• Create an entity for the junction table
• Demonstrate the creation of a one-to-many relationship
• Move to a many-to-many relationship

10
Create Models and Connect Them Through Relationships

Now that you are done with the videos of section 3, let’s assess your learning. Here, are a few questions, followed by 4 options, out of which 1 is the correct option. Select the right option and validate your learning!

Performing Querying Operations

1
Reading from the Database

The first obvious type of query we need to deal with is the read query of course.

• Read all rows from a table
• Use SingleOrDefaultAsync to load a single row

2
Reading with LINQ

Some queries, especially the more complex ones can be done in LINQ too.

• Use LINQ queries to perform the same operations as in the previous vide

3
More CRUD Operations

Having worked with reading operations, it is now time to work with create, update and delete operations.

• Write a new row to a DB table
• Update a row in the table
• Delete a row using the primary key

4
Loading Strategies

Loading strategies are important for loading related data through navigation properties.

• Learn about the need for loading strategies
• Show examples of explicit loading with Reference and Collection
• Mention that Lazy Loading is not yet supported by EF Core

5
Eager Loading

Eager loading is the most efficient way to pre-load related data.

• Perform the previous video’s operations using Eager Loading this time

6
Query Object Pattern

Query Objects are a powerful way to make complex queries without having to maintain complex methods with long names.

• Mention Services and Repositories but do not focus on them
• Implement a query object

7
Performing Querying Operations

Now that you are done with the videos of section 4, let’s assess your learning. Here, are a few questions, followed by 4 options, out of which 1 is the correct option. Select the right option and validate your learning!

Advanced EF Core

1
Seeding the Database

Entity Framework Core does not come with a built-in seeding mechanism and seeding is a very common practice in database systems.

• Create a class with extension methods for AppDbContext
• Load some data in a few tables
• Seed the database from within Startup.cs

2
Working with Transactions

Although Entity Framework Core provides transactions right out of the box with DbContext, sometimes we need to take full control.

• Learn about the SaveChanges and SaveChangesAsync works transactionally
• Execute a simple transaction

3
Raw SQL Queries

We need to present raw SQL queries.

• Execute a simple raw SQL query
• Create a stored procedure with Visual Studio
• Execute the stored procedure with raw SQL

4
Handling Concurrency

When multiple users attempt to edit a single entity, concurrency issues arise.

• Identify the problem
• Solve the problem with a rowversion column

5
Working with an Existing Database

Sometimes it's not possible to start with a code first approach.

• Create a new database using the SQL Server Object Explorer
• Install EF Core
• Scaffold models and DbContext

6
Advanced EF Core

Now that you are done with the videos of section 5, let’s assess your learning. Here, are a few questions, followed by 5options, out of which 1 is the correct option. Select the right option and validate your learning!

You can view and review the lecture materials indefinitely, like an on-demand channel.
Definitely! If you have an internet connection, courses on Udemy are available on any device at any time. If you don't have an internet connection, some instructors also let their students download course lectures. That's up to the instructor though, so make sure you get on their good side!
4.1
4.1 out of 5
77 Ratings

Detailed Rating

Stars 5
30
Stars 4
27
Stars 3
16
Stars 2
3
Stars 1
1
00d4da7dce468914528ed59c058f16ec
30-Day Money-Back Guarantee

Includes

4 hours on-demand video
Full lifetime access
Access on mobile and TV
Certificate of Completion