---
title: "How to get multiple tables using Entity Framework Core"  
description: "How to get multiple tables using Entity Framework Core"  
author: "Revati S Misra"  
published: 2023-09-05  
updated: 2023-09-06  
canonical: https://www.mindstick.com/forum/159848/how-to-get-multiple-tables-using-entity-framework-core  
category: "asp.net core"  
tags: ["entity framework", "database table", "asp.net core"]  
reading_time: 2 minutes  

---

# How to get multiple tables using Entity Framework Core

How to get [multiple](https://www.mindstick.com/blog/12797/iowa-is-expected-to-see-heavy-growth-in-multiple-sectors) [tables](https://www.mindstick.com/articles/336597/introduction-of-html-tables-for-web-development) using [Entity Framework](https://www.mindstick.com/articles/1566/crud-operations-using-entity-framework-code-first-approach) Core

## Replies

### Reply by Aryan Kumar

To get multiple tables using [Entity](https://www.mindstick.com/forum/160562/database-connectivity-using-entity-framework-database-first-approach) [Framework](https://www.mindstick.com/forum/34615/software-framework-vs-library) Core, you can use the `DbSet` class. The class `DbSet` represents a collection of entities from a single table. You can load related entities from another table into the current entity using the include method.

For example, the following code gets all the customers and their orders in one LINQ call:

C#

```plaintext
var customers = context.Customers.Include(c => c.Orders);
```

This code will first loads all the customers from the `Customers` table. Then, load all the orders for each customer from the `Orders` table.

You can also use the `Include` method to load multiple related entities in one LINQ call. For example, the following code gets all the customers, their orders, and the products that they ordered in one LINQ call:

C#

```plaintext
var customers = context.Customers.Include(c => c.Orders).Include(c => c.Orders.Products);
```

This code will first loads all the customers from the `Customers` table. Then, load all the orders for each customer from the `Orders` table. Finally, all products ordered by each customer are loaded from the `Products` table.

Here are some other things to keep in mind when getting multiple tables using Entity Framework Core:

- You can join tables in a LINQ query using the join operator.
- You can use the `Where` operator to filter the query results.
- You can use the `OrderBy` operator to sort the result of your query.
- You can use the `Take` and `Skip` operators to paginate the query results.


---

Original Source: https://www.mindstick.com/forum/159848/how-to-get-multiple-tables-using-entity-framework-core

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
