Welcome to the C# Entity Framework tutorial (Code First). We have created simple tutorials from beginners to professionals to learn the all the features & concepts of the Entity Framework Code First in C#. This tutorial is for those who wants to learn Entity Framework from scratch.
This entity framework tutorial requires a working knowledge of C#, Visual Studio 2013 and MS SQL Server.
Entity Framework Tutorial
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 by Microsoft. You can find the Entity Framework project on the codeplex.
Table of Content
- Introduction to Entity Framework
This Tutorial Covers the Brief Introduction and concepts behind the entity framework.
- 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.
- Introduction to Code First
This Chapter introduces you to Code First and advantageous of Code First against other models like database first/model first
- 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.
- 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.
- Database Connection
Learn about how entity framework discovers and create a database based on the convention.
- Database Initialization
This tutorial we will look at how to initialize the database using the in-built initializers provided by the entity framework
- Custom Database Initializer in Entity Framework
Here we look at how to create the custom database initializer
- Seed Database in entity Framework
Here we look at how to pre-populate (Seed) the database with default data.
- Code First Conventions in Entity Framework
Learn about how Entity framework Configures the database using the Conventions.
- Data Annotations in entity framework
This tutorial explains how to use the Data Annotations to configure the database schema. The Data annotations attribute help Entity Framework Code First to apply the certain rules on entity models. The following are the list of Data Annotation attributes available in the Entity Framework Code First
- Fluent API in Entity Framework
This Tutorial Gives a brief Introduction to Fluent API
- Fluent API in Entity Framework Code First
This Tutorial explains how to use Fluent API in Entity Framework Code First
- Configure Entity Mappings Using Fluent API
This Tutorial explains how to use Fluent API To Configure the Entities
- Configure Entity Properties Using Fluent API
This Tutorial explains how to use Fluent API To Configure the Properties of Entities
- Relationships in entity Framework
Learn about how entity framework handles various relationships like one to one, one to many and many to many.
- One to one relationship in Entity Framework
Configuring the One to One relationship in Entity Framework
- One to Many relationships in Entity Framework
Configuring the One to Many relationships in Entity Framework
- Many to Many relationships in Entity Framework
Configuring the Many to Many relationships in Entity Framework
- Code First with existing database
Learn how to use Code First with existing database. You can connect to your existing database and reverse engineer the entity models from the database
- DBContext in Entity Framework.
The DbContext is often referred 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.
- DBSet in Entity Framework
The DBContext class exposes the DBSet Class for the 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.
- LINQ to Entities Tutorial
LINQ to Entities Tutorial in simple and easy steps. Learn to Query, Add, update.delete records from the database using LINQ to entities in entity framework
- Querying LINQ to Entities in Entity Framework
Learn how to Write a simple query, which retrieves the collection of data from the table. Learn how to Filter the data with where clause. Learn how to Sort the output using orderBy method.
- LINQ to entities Finding the Single Entity
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.
- Projection Queries in 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
- Loading Related Data
Find out how to retrieve Related data from the Entities using Navigation Properties.
- Join Queries in Entity Framework
Learn to use Join Queries to Load Data from multiple tables using both query & Method syntax
- Logging database operations Entity Framework
Entity Framework starting 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
- Querying LINQ to Entities in Entity Framework
- 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.
- Eager Loading in Entity Framework
Eager loading is a process where related entities are loaded along with the target entity
- Explicit Loading in Entity Framework
Explicit Loading is a process where related entities are loaded with an explicit call. Explicit loading works very similar to Lazy Loading, but the loading of the related entities happens only after an explicit call
- Persistence in Entity Framework
Learn how entity framework handles persistence
- 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.
- Adding New Entities in Entity Framework
- Update Record in Entity Framework
- Deleting Records in Entity Framework
Entity Framework Resources
- Entity Framework Official Site
- Entity Framework – Wikipedia, the free encyclopedia
- Data Developer Center – Entity Framework