Entity Framework 6


Entity Framework 6

Authors: Julie Lerman, Michael Perry

Entity Framework (EF) is Microsoft's Object Relational Mapping (ORM) tool for the .NET framework that allows you to rapidly create a data access layer for your applications. This... Read more

What you will learn

  • Creating Code-first based models to represent your database entities
  • Use of the DbContext class
  • Mapping database tables to EF model classes
  • Retrieving and updating data using EF
  • Using EF Migrations to create and manage your database schema
  • Using Domain-Driven Design Concepts with Entity Framework
  • Integration testing of Entity Framework
  • Reverse engineering a database to an Entity Framework model


You should have a working knowledge of the C# language and of SQL databases to start this path.


You will want to start by getting a handle on everything that Entity Framework 6 can do. The courses in this section will guide you from just starting out with Entity Framework to the use of its most advanced features, regardless of if you have used an ORM before or not.

Getting Started with Entity Framework 6

by Julie Lerman

Mar 11, 2020 / 2h 36m

2h 36m

Start Course

If you are new to Entity Framework, Microsoft’s framework for integrating data access into your .NET applications, this is the place to start. You will gain an understanding of:

  • What Entity Framework is for
  • How Entity Framework works
  • Where it belongs in your software architecture and how to get it there
You’ll gain hands on experience with the basics of using EF from designing a simple model to interacting with that to persist data from your application.

In addition to getting developers started with EF and prepared to learn and take advantage of more advanced techniques, this course will provide managers with the info they need to help them with decision making when planning a development stack.

We’ll be using Visual Studio 2015 and .NET 4.6 for demos.

Table of contents
  1. Overview of Entity Framework 6
  2. Creating a Code-based Model and Database
  3. Using EF to Interact with Your Data
  4. Using EF in Your Applications

Advanced Entity Framework 6: The Ninja Features

by Julie Lerman

Apr 20, 2020 / 6h 9m

6h 9m

Start Course

Entity Framework 6 brought major improvements to EF allowing developers to align their data access with advanced software practices. This was the first version of EF that became open-source and gained a lot from developer community input. Features with broad appeal such as stored procedure mappings in Code First, support for the Async/Await pattern when executing queries and commands, simplerpatterns for unit testing, and built-in database logging capabilities were among the very popular enhancements. EF6 is also very extensible thanks to custom Migrations, custom mapping conventions, and the introduction of Dependency Injection patterns to open up low-level DbContext configuration. It also gained new methods and properties to allow simpler and smarter coding patterns. This course dives into many of the advanced features in EF6, ensuring that you understand not only what each is for, but how it works, scenarios where you can benefit from it, and gotchas you should watch out for. This course provides a comprehensive look at what EF6 adds to Entity Framework, and it will leave you with the ability to truly benefit from all of the Ninja power that' was added to this version of EF.

Table of contents
  1. Overview of What's New in EF6
  2. Performance and Stability Improvements
  3. Stored Procedure Mappings for Code First
  4. Custom Code First Conventions
  5. More Code First Goodies
  6. Enhancements to Code First Migrations
  7. Improved Database Interaction
  8. Code-based DbContext Configurations and Interceptors
  9. Sometimes, It's the Little Things


As you continue your journey with Entity Framework, you will want a comprehensive understanding of how it to integrate EF into your enterprise applications and use it across teams. The courses in this section will teach you how to design and build robust data access layers that use time-tested and proven patterns. You will also learn how to use Entity Framework Migrations to manage the structure of your database in a team based environment, allowing you to rapidly evolve your database schema as your needs change.

Entity Framework in the Enterprise

by Julie Lerman

Sep 23, 2016 / 4h 41m

4h 41m

Start Course

Have you reached the limitation of the introductory lessons on Entity Framework when trying to implement EF into your real world business solutions? In this course, Entity Framework in the Enterprise, you will learn advanced patterns for incorporating Entity Framework into enterprise level architecture. First, you'll learn patterns for encapsulating your EF logic and how to choose which best suits your needs depending on what you need to accomplish. Next, discover how to align your EF code with the many beneficial patterns, from Domain-Driven Design in your software from breaking data models apart for Bounded Contexts, to persisting tightly-controlled aggregates. Finally, testing code without hitting the database gets easier with the test mock support introduced in EF6. You'll also get to see how to mock a variety of EF database interactions that are triggered by your business logic. When you're finished with this advanced Entity Framework course, you'll not only better understand using EF in your real-world software, but you may gain some general software architecture wisdom along the way. Software required: Visual Studio 2013 or higher, Entity Framework 6 or higher.

Table of contents
  1. Course Overview
  2. Architecting a Data Layer
  3. Understanding EF Encapsulation and the Great Repository Debates
  4. Implementing Encapsulation Patterns with Entity Framework
  5. Managing Complex Domains and Data Models
  6. Refactoring into Bounded Contexts: A Walkthrough
  7. Handling the State of Disconnected Graphs
  8. Mapping DDD Domain Models with EF
  9. Testing Your Apps When Entity Framework Is Involved

Entity Framework Migrations for Large Teams

by Pluralsight

Aug 16, 2016 / 1h 51m

1h 51m

Start Course

Entity Framework (EF) is the preferred mechanism for accessing a SQL database in an enterprise application. EF migrations keep the schema of the database in sync with the application. But when teams use EF migrations collaboratively, some challenges emerge. In this course, Entity Framework Migrations for Large Teams, you'll Learn how to use EF Migrations with Git and TFS source control. First, you'll learn to use Entity Framework Migrations with Git or TFS version control. Next, you'll learn to manage simple and complex database changes. Finally, you'll learn how to discover and resolve migration issues. By the end of this course you'll learn all of the techniques required in order to work better together with your team.

Table of contents
  1. Course Overview
  2. Entity Framework Migrations for Large Teams
  3. Following a Workflow
  4. Handling Special Cases
  5. Resolving Common Problems


Testing is a critical component in the lifecycle of any application, so in this section, you will learn what it takes to properly test you Entity Framework applications. You will also learn about some available tooling specifically designed for working with existing databases and how it can simplify the use of EF with these databases. When finished with this path, you will have a thorough knowledge of all of Entity Framework's capabilities and how to use it in all of your applications.

Integration Testing of Entity Framework Applications

by Michael Perry

May 11, 2017 / 2h 21m

2h 21m

Start Course

Having a good integration test suite is your greatest asset. In this course, Integration Testing of Entity Framework Applications, you'll learn that a good integration test suite is the best way to ensure the quality of your Entity Framework application. First, you'll set up a Continuous Integration server to rebuild a database and run all integration tests on every checkin. Next, you'll keep your test readable and resilient to change, so that they help you implement new features rather than hold you back. Finally, you'll find the balance between unit tests and integration tests so that you use the best technique in every case. After this course, you'll know that by investing in a quality test suite you'll increase both velocity and quality.

Table of contents
  1. Course Overview
  2. The Importance of Testing the Data Access Layer
  3. Deploying a Database to the Test Environment
  4. Isolating Integration Tests
  5. When and How to Unit Test
  6. Structuring a Readable Test

Code-first Entity Framework with Legacy Databases

by Pluralsight

May 16, 2016 / 2h 52m

2h 52m

Start Course

With EDMX support fading away, it's even more important to use code-first as EF7 approaches. Most generators are rigid and don't provide you any flexibility in how the code is to be generated. But in this course, Code-first Entity Framework with Legacy Databases, we will be using the "Entity-Framework Reverse POCO Generator", a free visual studio tool, available at www.ReversePoco.com. This generator has been designed from the ground up to be customizable, and produce the code you would have done if you hand-coded it yourself. This course will show you what each of the various settings has on the generated code, and you'll also learn how to create separate data and model projects, as well as create repositories, unit tests and integration tests. By the end of this course, you will be able to flexibly generate code that meets your needs.

Table of contents
  1. Introduction and Project Overview
  2. Generating Code First Types from an Existing Database
  3. Isolating the Relevant Database Objects
  4. Organizing the Generated Code
  5. Customizing the Generated Code
  6. Working with Entity Framework Migrations
  7. Testing the Code-first Access Layer