Tutorials on ASP.NET Core, Blazor, jQuery, JavaScript, Entity Framework, Identity, WordPress, SQL, HTML & more


Configure Many-to-Many relationship using Fluent API in Entity Framework Core

Last Updated: November 26, 2024

fluent api many to many ef core

Entity Framework Core Many-to-Many Relationship is configured through Fluent API. We first add collection navigation property on both the entities and then add the join entity type with the UsingEntity() method.

(more…)

Configure One-to-One relationship using Fluent API in Entity Framework Core

Last Updated: November 26, 2024

fluent api one to one ef core

We can configure Entity Framework Core One-to-One Relationship by the use of Fluent API. The One-to-One Relationship is established by using the HasOne - WithOne pattern. Note that we can also create this relationship by using EF Core Conventions.

(more…)

Configure One-to-Many relationship using Fluent API in Entity Framework Core

Last Updated: November 22, 2024

fluent api one to many relationship

Entity Framework Core One-to-Many Relationship is established between 2 entities by the use of Fluent APIs. This relationship is configured by the use of Has/With pattern.

(more…)

Fluent API in Entity Framework Core

Last Updated: November 6, 2024

fluent api ef core

Entity Framework Core Fluent API is used to build model based on entity classes. We can also override the default Conventions of Entity Framework Core using Fluent API when targetting the database schema as Fluent API has higher precedence than conventions and data annotations.

(more…)

Configurations in Entity Framework Core

Last Updated: November 4, 2024

configurations ef core

Entity Framework Core Configurations allow us to override the default conventions in order to create database schema and mappings. We already saw the concept of Conventions in Entity Framework Core where we understood how default conventions work. If we want to override the conventions then apply the configurations and customize the EF Core model to database mappings.

(more…)

Conventions in Entity Framework Core

Last Updated: November 26, 2024

conventions ef core

Entity Framework Core Conventions are default rules by which the Database Schema is created based on Entity classes and DbContext. For example - the table names, column names, relationships, primary & foreign keys are all created based on these conventions.

(more…)

Delete Records in Entity Framework Core

Last Updated: November 17, 2024

delete records ef core

Entity Framework Core API executes the DELETE statement in the database for the entities whose EntityState is set as Deleted. The Remove() method of the DbContext is used for deleting records from the database.

(more…)

Update Records in Entity Framework Core

Last Updated: November 17, 2024

update records ef core

The Entity Framework Core executes UPDATE statement in the database for the entities whose EntityState is Modified. The DbContext's Update() update method is used for performing the updation of records in the database.

(more…)

Read Records in Entity Framework Core

Last Updated: November 13, 2024

read records ef core

Entity Framework Core Reads Record from the database through the DbContext object. For example we can get all records from the database by using the below code.

var emp = context.Employee;

Here "context" is the object of DbContext class and "employee" is the entity whose reacords Entity Framework Core is reading from the database.

We can also fetch a particular employee from database. For example in the below code we are fetching the employee with name as Matt.

var emp = await context.Employee.Where(e => e.Name == "Matt").FirstOrDefaultAsync();
(more…)

Insert Records in Entity Framework Core

Last Updated: November 17, 2024

insert records ef core

In this tutorial we will learn to Insert Records in Database with Entity Framework Core. EF Core can insert a single record or bulk records at the same time. Note that entities that have EntityState value as 'Added' are insterted to the database.

(more…)