Entity Framework Core 2.1: What's New Playbook

The 2.1 update to EF Core brings over 500 changes since EF Core 2.0. In this course, you’ll learn how to take full advantage of the most impactful new features like view mapping, server-side GroupBy processing, seeding and more.
Course info
Rating
(20)
Level
Intermediate
Updated
Oct 9, 2018
Duration
3h 22m
Table of contents
Course Overview
Setting the Stage for the EF Core 2.1 Release
Seeding the Database and In-Memory Test Provider
Exerting More Control Over Saving with System Transactions
Tapping into the Pipeline with New Tracking Events
Lazy Loading With and Without Proxies
Mapping More .NET Types and Enums with Value Conversions
Transferring the GroupBy Effort to the Server
Introducing Query Types for More Flexible Data Models
Benefiting from Minor Changes with Major Impact
Description
Course info
Rating
(20)
Level
Intermediate
Updated
Oct 9, 2018
Duration
3h 22m
Description

Every application uses data, and a thorough knowledge of Entity Framework Core is key to building successful .NET and .NET Core applications. In this course, Entity Framework Core 2.1: What's New Playbook, you’ll learn how to take full advantage of the most impactful features added to EF Core 2 in this update. First, you’ll learn how to use some returning features that work quite differently than they did in EF6, for example, data seeding, lazy loading and GroupBy queries. Next, you’ll explore some completely new features such as view mapping, change tracking event handlers, and type conversions. Finally, you’ll discover some of the small changes that can have a big impact on your code. When you’re finished with this course, you’ll have a deep knowledge of these important features in EF Core 2.1, enhancing your capability to create efficient and intelligent data access logic in your software.

About the author
About the author

Julie Lerman is a Microsoft MVP, .NET mentor and consultant who lives in the hills of Vermont. You can find Julie presenting on data access and other Microsoft .NET topics at user groups and conferences around the world. Julie is the author of the highly acclaimed "Programming Entity Framework (with a second edition coming soon) and authors the MSDN Magazine Data Points column.

More from the author
Entity Framework Core 2: Mappings
Intermediate
1h 59m
May 16, 2018
Entity Framework Core 2: Getting Started
Beginner
2h 42m
Feb 6, 2018
More courses by Julie Lerman
Section Introduction Transcripts
Section Introduction Transcripts

Course Overview
Welcome to Pluralsight. My name is Julie Lerman, and you might know me as one of the most recognized authorities in the world on Entity Framework, Microsoft's data access platform for. NET. I'm so happy to be able to share with you the latest update to EF Core Version 2. 1. Although it's a minor update, it contains over 500 changes since EF Core 2. 0 was released. But it's not just bug fixes. This update includes some major new features and so many improvements, and that's what this course will focus on. Some of the topics that we'll cover include the return of lazy loading with new options to make it more lightweight, a new way to create C data in your data store, value converters to help you solve data-type mapping problems, and a completely new way to map database views and other read-only data. By the end of this course, you'll have a deep understanding of how to implement these and some notable features. I worked hard to discover the limitations and nuances so you'll have the knowledge you'll need to avoid, or at least solve, problems you might encounter. You'll also learn about some smaller features that I've found to be really useful. Before beginning the course, you should be familiar with Entity Framework Core 2. I recommend watching the EF Core 2 Getting Started course, as well as the EF Core 3 Mappings course. I hope you'll join me on this journey to learn how to really benefit from this very rich update with the Entity Framework Core 2. 1 What's New Playbook, at Pluralsight.

Setting the Stage for the EF Core 2.1 Release
Hello. Welcome to the Entity Framework Core 2. 1: What's New Playbook. I'm Julie Lerman, and I'm really looking forward to sharing with you some of the great new features and improvements that came to the 2. 1 version of EF Core. In this module, I want to provide you with something of a status report about EF Core as a whole and where this new version 2. 1 fits in. I'll address questions about parity with EF6 and share the EF team's vision for Entity Framework Core. Then I'll be sure to let you know what to expect from this course, and since I'll can't possibly cover every change that has come to this version, there are over 500, you know, I will guide you to some helpful resources.

Seeding the Database and In-Memory Test Provider
Welcome back to EF Core 2. 1: What's New. I'm Julie Lerman, and in this module, we'll focus on a new way to seed data into your database. In this module, you'll get an overview of the use cases for this new seeding feature, among the other options you've got for seeding. Then you'll see this new HasData method being used in its simplest scenario. Then after that, we can explore using it when the entities that you're seeding data for are more like your real-world code. You'll learn how the seeding interacts with primary keys; how to seed related data, as well as owned types; how to seed data for properties with private setters or that exist only as shadow properties in your models; you'll learn about patterns for seeding data for classes that generate their own values; and you'll see how you can use this new feature to seed data in your tests. If you plan to follow along with this demo, here's some useful information for getting set up. I'll be using Visual Studio 2017 on Windows, but because my samples use. NET Core projects, you can also use Visual Studio Code if you prefer, and that can be on Windows, MacOS, or Linux. Be sure to grab the course downloads. The starting point for this module is in the BEFORE solution for this module. Because you'll been using. NET Core 2. 1. 1, you'll need to be sure the. NET Core 2. 1 SDK is installed on your computer. If you go to. dot. net, you can install that for whichever operating system you're on. If you're using Visual Studio Code, then you'll need to use the CLI versions of the migrations commands in your terminal window. Here's a list of the commands I'll be using in Visual Studio 2017 and their CLI counterparts, in case you're not familiar with them.

Exerting More Control Over Saving with System Transactions
Welcome back to the Entity Framework 2. 1: What's New Playbook. I'm Julie Lerman, and this module will focus on EF Core's new support for more customized transaction handling with System. Transactions. I'll give you a quick look at the transaction support that's already been part of EF Core and provide some highlights of the new System. Transactions support in 2. 1. And I'll provide insight into why you would want to use System. Transactions over the other options we have in EF Core 2. 1, as well as the current limitations that we have and why those exist. Then you'll learn a few patterns for customizing how and when transactions are handled when you use System. Transactions to orchestrate them.

Tapping into the Pipeline with New Tracking Events
Hello. I'm Julie Lerman. Welcome back to the EF Core 2. 1: What's New Playbook. In this module, you'll learn about the new events that EF Core exposes from the ChangeTracker's pipeline, Tracked and StateChanged. We'll begin with a quick look at the solution, which is included in the course downloads. I'll show you how to tap into those events in the DbContext, and we'll watch them in action. You'll also learn how to wire up the events to specific instances of the DbContext. ChangeTracker events are also exposed through. NET Core's logger, and I'll show you how to define the logger so that it will show you the change tracking events.

Lazy Loading With and Without Proxies
Hello. Welcome back to EF Core 2. 1: What's New. I'm Julie Lerman. In this module, we'll dig into the return of lazy loading to Entity Framework Core. I'll start with a short overview of lazy loading looks like in EF Core 2. 1. Then we'll take a look at the pre-created project, which you can get in the downloads, as well as the domain that I'll be using for the demos in this module, since we won't be building that from scratch. There are now two ways to implement lazy loading, so we'll start by learning the one that might be most familiar to you if you've used it before, and that's the workflow that employs runtime proxy objects. It's similar to how lazy loading worked in Entity Framework, although there are some important differences you'll need to be aware of. Once you've seen that in action, we'll dig a little more deeply into some of the details about how the proxies work and some of their limitations, including some application types that you just can't use them in. With an understanding of those limitations, I'll then explain some of the differences between using proxies for lazy loading and the other way that you can implement lazy loading in EF Core 2. 1 that doesn't use proxies. Then you'll learn how to use that implementation and then go even further by removing any Entity Framework Core references in the projects that contain your business classes and shouldn't know anything about Entity Framework Core. I did spend a little more time with this than I had anticipated because there were a lot of interesting details to uncover and share with you. So, let's get started.

Mapping More .NET Types and Enums with Value Conversions
Hello. Welcome back to EF Core 21. : What's New. I'm Julie Lerman. In this module, you'll learn about the new ValueConverter feature that's been introduced in this update to EF Core. In this module, I'll start by providing an explanation of the purpose of value converters and some insight into how they work. Then I'll show you a few of the built-in converters. First, I'll use one that can transform time values when you want to store a duration, not the actual time of day, and another for transforming enums into strings. Then I'll show you how to define your own transformation logic, and as an example, I'll store color objects as strings, and then materialize the strings back to color objects. With this in hand, I'll then show you how to define and use your own value converters. Not only is this a useful feature, but I find it fun to work with. So let's dive right in.

Introducing Query Types for More Flexible Data Models
Hello. Welcome back to Entity Framework Core 2. 1: What's New. I'm Julie Lerman, and in this module, you'll learn about the new QueryType feature, which enables patterns we've never been able to use in any previous version of Entity Framework. We'll begin with a high-level look at query types so that you understand what they are and what problems they solve. Then I'll show you the various patterns that query types support. We'll start with mapping database views in your model and then executing queries against them. Then you'll see how query types allow you to predefine queries in the data model, both with LINQ or raw SQL. Then I'll show you how you can use query types to captures the results of raw SQL queries so you don't have to add and track unnecessary entities to your model. And because this is the first iteration of query types, there are still some gaps with their capabilities. I'll point out some of these limitations along the way.

Benefiting from Minor Changes with Major Impact
Hello. Welcome to EF Core 2. 1: What's New. I'm Julie Lerman, and in this module, I'm combining a number of smaller changes and new features of EF Core that are still notable even though they're small. You'll get an introduction to the new MinBatchSize feature that can help with performance when you're batching a small number of commands to send to the database. You'll also see how the database column ordering has changed when letting EF Core create your database for you. For those of you who use the command-line interface, there's a small but welcome change to how you can access EF Core's CLI tools. And if you use raw SQL with EF Core, you should definitely be aware of the new analyzer to spot potential SQL injection, as well as why this analyzer was added. And then we'll look at a feature I'm especially fond of, which is related to overriding the default class constructors in your domain classes. Okay, so let's jump right in.