This course is for developers who are familiar with the basics of using EF Core to create models, migrate databases, interact with data and incorporate EF Core into simple applications, and will prepare you for working on production software.
Entity Framework Core 2 is the latest version of Microsoft’s modern OR/M data access platform. In this course, Entity Framework Core 2: Mappings, you’ll explore how to efficiently utilize the latest version of Entity Framework Core to prepare yourself to work on production software. First, you’ll learn how to best build and interact with many-to-many and one-to-one relationships. Next, you'll discover how to take advantage of additional mappings such as the new shadow properties, scalar function support, and owned entities. Finally, you'll go over how to work with database views. By the end of this course, you'll be able to elevate your skill set and provide yourself with the tools you need to build your production application.
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.
Course Overview Welcome to Pluralsight. My name is Julie Lerman, and you may know me as one of the most recognized authorities in the world on Entity Framework, Microsoft's data access platform for. NET. I'm looking forward to help you get beyond the basics with your knowledge of Entity Framework Core 2. My latest course, Entity Framework Core 2: Mappings, focuses on specialized mappings that let you persist your business objects into your database. This course will give you a deeper understanding of how to work with many-to-many and one-to-one relationships in your models. You'll also learn how to leverage the new shadow properties feature, which lets you store information like audit data without it getting in the way of your business classes. The new owned type mapping lets you map complex types and value objects as part of your rich domain model. You'll also learn how to map database scalar functions and database views. All of these features are important for elevating your skill set beyond what you learned in the getting started demos and providing you with the tools you need to build your production applications. Before beginning this course, you should be familiar with the basics of EF Core 2, and you can do that by watching my course Entity Framework Core 2: Getting Started. I hope you'll join me on this journey to advance your data persistence skills with Entity Framework Core 2: Mappings course here at Pluralsight.
Mapping and Interacting with Many-to-many Relationships Hello. I'm Julie Lerman, and welcome back to Entity Framework Core 2: Mappings. This module will focus on many-to-many relationships. And we'll start by reviewing the many-to-many relationship between Samurais and Battles in the model that we created in the EF Core 2: Getting Started course. You'll then learn how to define a many-to-many relationship that EF Core will be able to work with since EF Core can't infer the relationship without some mapping information from you. With the mapping in place, you'll learn about a variety of ways to create query and modify data in a many-to-many relationship. You'll also see how other factors impact EF Core's behavior. For example, if the parts of the relationship are InMemory or not, as well as whether or not the DbContext is tracking the objects while you're making changes.
Mapping and Interacting with One-to-one Relationships Hello. I'm Julie Lerman, and welcome back to Entity Framework Core 2: Mappings. This module will focus on one-to-one relationships, and we'll start by reviewing the one-to-one relationship that we created in the EF Core 2: Getting Started course. With that in hand, you'll learn how EF Core reads your model and infers those relationships, as well as how you can use the Fluent API to affect that interpretation. Then we'll move onto interacting with the data, and you'll see what happens when you add a child in a one- to-one relationship, and this may not be as straightforward as you would imagine because there are a number of factors that can affect EF Core's behavior. Then, you'll learn about changing and removing a child in a one-to-one relationship. Again, this is affected by factors like tracking and nullability that will affect EF Core's behavior. So these are really important lessons to pay attention to.
Using Shadow Properties to Persist Data You Don’t Want in Your Entities Hello. Welcome back to Entity Framework Core 2: Mappings. I'm Julie Lerman, and in this module, we'll continue our journey beyond the EF Core 2 mapping basics to explore EF Core's shadow properties, which allow you to persist data that's not defined in your entities. You'll learn how to define shadow properties, how to populate them, and how to leverage them in queries. I'll start with a simple example, but then I'll show you a more real-world way to define and populate shadow properties.
Leveraging the New Owned Type Feature for Value Objects and Complex Types Hello. Welcome back to EF Core 2: Mappings. In this module, you'll learn about one of my favorite features of EF Core, owned types, also known as owned entities. This feature gives you the ability to have EF Core map your custom types, as well as value objects to your database. Owned types replaces the complex type of earlier versions of Entity Framework. I'll start by making sure you understand why owned types are an important feature. Then we'll add a new type into the model and I'll show you how to map it to the database as an owned type using the DbContext mappings. With the code changes in place and the database updated with a new schema, you'll then see the owned types in action. There are a few scenarios that don't work as expected in the current version of EF Core. They're both on the docket to get fixed, but in the meantime, I want to be sure you're prepared for them and know how to work around these issues. Then, I'll evolve my new type into a domain-driven design value object so you can see that the own type mapping still does its job. So let's get started.
Mapping Database Scalar Functions Hello. This is Julie Lerman, and welcome back to EF Core 2: Mappings. In this module, you'll learn how to map scalar functions from your database that you can use in EF Core queries. We'll start by clarifying what a scalar function is and what it's not. Then you'll learn how to map your own user-defined scalar functions to your DbContext and use that in queries to return that scalar data or to apply a filter in the database query. After this, we'll look at a scalar function that performs a calculation, and how to map that so it cannot only be used in queries against your relational database, but also when using EF Core's InMemory provider for testing. You'll also learn about working with scalar functions that are built into the database. And then wrap up with a clarification of how these mappings differ from EF Core's support for client-side evaluation of your own. NET based methods that you use in queries. So, let's get started.
Working with Database Views Hello. This is Julie Lerman, and welcome to the last module of Entity Framework Core 2: Mappings. This module will help you be able to use database views with EF Core 2. And notice I said use, not map. That's because database views aren't really supported yet. Although with EF Core 2. 1 coming, that's going to bring much better support for views. But still, you can query against database views with EF Core 2, and I wanted to be sure you saw this in action. I'll warn you now there will be a few hacks along the way, but in the end, you'll be able to include your database views in your model. In addition to understanding these limitations, you'll learn about creating classes that will capture the view results, see how you can query the view with LINQ. We'll start with a view that's already in the database. I'll also show you how to define a view using raw SQL in a migration so that if you have new views you want to add to your database, you can still get them in there using migrations and share that across your team and in production. I'll also point out some other current limitations and some gotchas to watch out for along the way. Then I'll give you a heads up about the type of support you can expect in EF Core 2. 1 for mapping to database views.