Complete Entity Framework Tutorial

Welcome to the Entity Framework tutorial using the Code First.  We have created simple tutorials for beginners to professionals to learn all the features & concepts of the Entity Framework. This tutorial is for those who want to learn Entity Framework from scratch.

This entity framework tutorial requires a working knowledge of the following

  • C#, 
  • Visual Studio 2015/2017/2019
  • MS SQL Server.

What is Entity Framework

The Microsoft Entity Framework is an ORM Framework.   The Entity framework sits between your application and the data store.  The applications use the Entity framework API for the database related operations. The Entity Framework maps all the database related operations to the database

Entity Framework is an open-source framework for Microsoft. You can find the Entity Framework project on the CodePlex.

Table of Content

Introduction to Entity Framework

  1. Introduction to Entity Framework
    This Tutorial Covers the Brief Introduction and concepts behind the entity framework.
  2. Getting Started with Entity Framework
    This tutorial discusses the various building blocks of the Microsoft Entity Framework. It also looks at the various terms used in the entity framework and its architecture. The Various Entity Data model like Conceptual, storage & mapping layers are covered here.


Best Entity Framework Books
The Best Entity Freamework Books, which helps you to get started with Entity Framework  

Introduction

  1. Introduction to Entity Framework Code First
    This chapter introduces you to Code First and advantageous of Code First against other models like database first/model first
  2. Code First Example
    This tutorial guides you through creating a simple Console application using the Code First Concepts. The Console application creates a Simple user model and shows you how to perform a simple CRUD operation on the user model.
  3. ASP.NET MVC Code First Approach
    This Entity Framework Tutorial guides you through creating the simple ASP.NET MVC Application using the Code First model.

Connecting to Database 

  1. Database Connection
    Learn about how the entity framework discovers and create a database based on the convention.
  2. Database Initialization
    This tutorial we will look at  how to initialize the database using the in-built initializers provided by the entity framework
  3. Custom Database Initializer in Entity Framework
    Here we look at how to create the custom database initializer

Seeding & Migrations

  1. Seed Database in Entity Framework
    Here we look at how to pre-populate (Seed) the database with default data.
  2. Code First with an existing database
    Learn how to use Code First with the existing database. You can connect to your existing database and reverse engineer the entity models from the database

Components of Entity Framework

  1. DBContext in Entity Framework.
    The DbContext is often referred to as the context is the class. This class interacts with the entity model and the database. Using DBContext we can run queries against the database to perform CRUD operations.
  2. DBSet in Entity Framework
    The DBContext class exposes the DBSet Class for each entity in the model. DBSet allows us to query the database using the IQueryable Interface. Learn about the Properties and methods of DBSet Class.

Configuring the Entity Framework

  1. Configure the Entity Data Model
    The table is not only about columns. We need to specify the data types, the length of each column, Primary Key, Foreign Key ETC. In EF this can be achieved in three ways. Default Conventions, Configurations &
    Custom Code Conventions. In this Tutorial and in subsequent tutorials, we take look at how to configure our database using these techniques
  2. Code First Conventions in Entity Framework
    Learn about how the Entity framework Configures the database using the Conventions.
  3. Data Annotations in Entity Framework
    This tutorial explains how to use the Data Annotations to configure the database schema. The Data annotations attribute helps Entity Framework Code First to apply certain rules on entity models. The following are the list of Data Annotation attributes available in the Entity Framework Code First  
    1. Table Attribute
    2. Column Attribute
    3. Key Attribute
    4. ComplexType Attribute
    5. ConcurrencyCheck Attribute
    6. Timestamp Attribute
    7. Databasegenerated Attribute
    8. ForeignKey Attribute
    9. MaxLength Attribute
    10. StringLength Attribute
    11. NotMapped Attribute
    12. Required Attribute
    13. InverseProperty Attribute

Fluent API

  1. Fluent API in Entity Framework
    This Tutorial Gives a brief Introduction to Fluent API
  2. Configure Entity Mappings Using Fluent API
    This Tutorial explains how to use Fluent API To Configure the Entities
  3. Configure Entity Properties Using Fluent API
    This Tutorial explains how to use Fluent API To Configure the Properties of Entities

Relationships in Entity Framework

  1. Relationships in Entity Framework
    Learn about how entity framework handles various relationships like one to one, one to many and many to many.
  2. One to one relationship in Entity Framework
    Configuring the One to One relationship in Entity Framework
  3. One to Many relationships in Entity Framework
    Configuring the One to Many relationships in Entity Framework
  4. Many to Many relationships in Entity Framework
    Configuring the Many to Many relationships in Entity Framework

Querying in Entity Framework

  1. LINQ to Entities Tutorial in Entity Framework
    Learn LINQ to Entities in simple and easy steps. Learn to Query, Add, update, delete records from the database using LINQ to entities in entity framework
  2. Querying in Entity Framework
    Learn how to write a simple query, which retrieves the collection of data from the table. how to filter the data with where clause. How to sort the output using the orderBy method.
  3. Finding the Single Entity using Find, First, FirstOrDefault, Single, SingleOrDefault in Entity Framework
    Learn how to return a single entity from the table using Primary Key. Learn how to return the results from the database using the other fields using the methods like First, FirstOrDefault, Single, SingleOrDefault, etc.
  4. Projection Queries in Entity Framework Entity Framework
    Projection queries in Entity Framework are used to create a query that selects from a set of entities in your model but returns results that are of a different type. Find out how to return an Annonymous or Custom Type from the LINQ To Entities Queries
  5. Join Queries in Entity Framework
    Learn to use Join Queries to Load Data from multiple tables using both query & Method syntax
  6. Loading Related Data in EF
    Find out how to retrieve Related data from the Entities using Navigation Properties.
  7. Lazy Loading in Entity Framework
    Lazy loading is the process where the Entity Framework delays the loading of an entity or collection of entities until the time application actually needs it.
  8. Eager Loading in Entity Framework
    Eager loading is a process where related entities are loaded along with the target entity
  9. Explicit Loading in Entity Framework
    Explicit Loading is a process where related entities are loaded with an explicit call. it works very similar to Lazy Loading, but the loading of the related entities happens only after an explicit call
  10. Include method in Entity Framework
  11. SelectMany Method in Entity Framework

Persisting the Data

  1. Save Changes in Entity Framework
    Learn how the entity framework handles Saving Changes to the database
  2. EntityStates in Entity Framework
    The Entity Framework Persists the Entities to the database by keeping track of State of Entities.  Entity Framework keeps track of, whether entities in memory are in sync with their corresponding rows in the database.
  3. Add Records/ Add Multiple Records in Entity Framework
  4. Update Record in Entity Framework
  5. Deleting Records in Entity Framework

Misc

  1. Logging database operations Entity Framework
    Entity Framework allows us to log the commands & queries sent to the database. The Logging is done by using the DbContext.Database.Log property, which can be set to a delegate for any method that takes a string. In this tutorial, we will look into how to implement the database log in Entity Framework
  2. Best Entity Framework Books

Entity Framework Resources

1 thought on “Complete Entity Framework Tutorial”

Comments are closed.

Scroll to Top