Call Us: +32 2 466 00 16
Follow Us:

Programming with LINQ and the Entity Framework

Training code

Upcoming sessions

28 Oct 2019
Book this course

Introducing LINQ

LINQ (Language Integrated Query) is a uniform way of querying different datasources. You will see what LINQ is, and see some examples of datasources you can use it on.


  • What is LINQ?
  • Introducing the LINQ query
  • Looking at the different implementations of LINQ
  • Extending LINQ
  • The LINQ project

Preparing for LINQ

In this module you will get an overview of the different additions and enhancements added to the .NET languages to make LINQ possible.


  • Recap of generics and delegates
  • Extension methods
  • Lambda expressions and functional programming
  • Anonymous types
  • Extension methods inside the Enumerable class
  • Using the Func delegates
  • Introduction to Expression trees

Writing queries with LINQ

In this module you will learn the basic query-functionalities of LINQ. You will learn how to filter, select, order and group your data.


  • The complete query syntax
  • Using query or method syntax for writing queries
  • Basic query operators from and where
  • Deferred query evaluation
  • Grouping
  • Using joins

Advanced query operators in LINQ

Sometimes you need somewhat more than just basic queries. You will see how to create union queries, aggregate data and more.


  • Set operators
  • Aggregate operators
  • Generation operators
  • Quantifiers operators
  • Partitioning operators
  • Element operators
  • Let operator
  • Other operators


How do you query XML ? You could have a look at XPath, but you can't really call that easy and readable. Linq to XML allows you to create queries using all the operators you have seen. Next to that, you can also use LINQ to XML to generate XML. No string-concatenation needed !


  • Generating XML with the new X* classes
  • Updating XML
  • Querying XML with LINQ
  • Transforming XML with LINQ instead of XSLT
  • Combining LINQ to XML with LINQ to Objects
  • Using VB's improvements for XML

The Entity Framework: Introduction

When a database is designed, the ideal is to normalize data, i.e. avoid duplicate data. When designing the objectmodel for an application you try to come up with a design which is best suited for solving your businessproblems. This means that mapping tables to classes one-on-one is often a bad idea. The Entity Framework allows us to map the relational world to the world of objects, allowing more complex mapping.


  • What is the Entity Framework?
  • The need for Object Relational Mapping
  • Decoupling conceptual data structure from logical data structure
  • Code Strategies: Database First, Model First, Code First
  • Querying data: APIs and LINQ

The Entity Framework: Building Entity Data Models

In this module you will learn the basics of creating models for the Entity Framework. Different mappingstrategies will be discussed.


  • The Entity-Data model
  • Visual Studio support
  • Defining Entities and Relationships
  • Supporting Inheritance, entity splitting and complex-types
  • Enumerations
  • Spatial types
  • Stored Procedures and Table Valued Functions
  • Using Raw SQL
  • Connection Resiliency
  • Using Interceptors
  • Using EF in N-Tier applications

Entity Framework Code Strategies

What comes first: the database or the application ? Entity Framework gives multiple options: database first, or model first. Or you just start writing your classes, using Code First.


  • Database First Strategy
  • Model First Strategy
  • Code First Strategy
  • Introducing Visual Studio T4 templates

DbContext Code Generation

In this module you will learn how Entity Framework tracks if you changed any data. You will also see how to create, update and delete data.


  • Using DbContext Entities
  • Using LINQ to Entities
  • Handling Stored Procedures
  • Understanding Change Tracking and Entity State Management
  • Entity State Management
  • Lazy Loading
  • Compiled Queries
  • Modifying data: Insert, Update, Delete
  • Async Query and Save
  • Intercepting database operations

Code First

Entity Framework Code First allows you to map your self-written classes to the database. Mapping will be defined by using attributes or by using the Fluent API. And you can even have a database generated for you when you run the application.


  • Code First Strategy
  • Code First database mapping
  • Code First Annotations
  • Code First Fluent API
  • Code First Database Initialization
  • Using stored procedures for CRUD operations in Code First
  • Code-Based Configuration

Code First Migration

When using Code First, you can have a database generated based on your code. What if you add some additional properties and classes later on? With Code First Migrations you can upgrade or downgrade your database to a specific version of your code. No dropping of databased needed.


  • Code First Version problems
  • Automatic Migrations
  • Code-based migrations
  • Migrate from code

Concurrency and Transactions

In this module you will learn how to use transactions while working with the database. You will also see how concurrency is handled by the Entity Framework.


  • Optimistic Concurrency in EF
  • Changing ConcurrencyMode
  • Concurrency with Code First Model
  • Implicit and Explicit Transactions
  • Using TransactionScope

Entity Framework Core

With .NET Core also comes Entity Framework Core. A new implementation of EF, which can run cross-platform, on Windows, Mac and Linux. You will get a look at the differences between EF Core and EF 6


  • Difference with Entity Framework 6
  • Scaffolding your project from an existing database
  • Generated code
  • Interacting with the database

Modeling your database with EF Core

Mapping in EF Core uses conventions, or Fluent API. You will see how to use Fluent API in EF Core.


  • Methods of configuration
  • Creating and applying migrations
  • Table and column mapping
  • Modeling properties
  • Value generated properties
  • Concurrent updates
  • Modeling relationships

LINQ is the integrated query language in VB.NET and C#. LINQ will provide you with a unified query language to query data coming from databases, XML documents, .NET collections, SharePoint,... This training starts with a deep dive into the concepts of LINQ. Part two will provide you with an in depth training on Entity Framework and shows you the different code strategies in querying databases.

This course targets professional C# or VB.NET programmers who are well experienced with .NET and who are interested to learn about the new programming models introduced with LINQ and Entity Framework.

© 2019 U2U All rights reserved.